Add Scripts/Powershell/SMB/Detailed Permission Report - All Shares.md
This commit is contained in:
@ -0,0 +1,21 @@
|
|||||||
|
**Purpose**:
|
||||||
|
This script will iterate over all network shares hosted by the computer it is running on, and will give *recursive* permissions to all folders, subfolders, and files, including hidden ones. It is very I/O intensive given it iterates recursively on every file/folder being shared.
|
||||||
|
|
||||||
|
``` powershell
|
||||||
|
$AllShares = Get-SMBShare | Where-Object {$_.Description -NotMatch "Default share|Remote Admin|Remote IPC|Printer Drivers"} | Select-Object -ExpandProperty Path
|
||||||
|
$Output = @()
|
||||||
|
ForEach ($SMBDirectory in $AllShares)
|
||||||
|
{
|
||||||
|
$FolderPath = Get-ChildItem -Directory -Path $SMBDirectory -Recurse -Force
|
||||||
|
ForEach ($Folder in $FolderPath) {
|
||||||
|
$Acl = Get-Acl -Path $Folder.FullName
|
||||||
|
ForEach ($Access in $Acl.Access)
|
||||||
|
{
|
||||||
|
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
|
||||||
|
$Output += New-Object -TypeName PSObject -Property $Properties
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Output | Export-CSV -Path C:\SMB_REPORT.csv -NoTypeInformation -Append
|
||||||
|
```
|
Reference in New Issue
Block a user