|
|
@@ -14,19 +14,28 @@ function Read-InputBoxDialog([string]$Message, [string]$WindowTitle, [string]$De
|
|
|
if ($inputname -eq $null -or $inputname -eq ""){
|
|
|
$inputname = Read-InputBoxDialog -Message "Insert UNC path to Scan" -WindowTitle "Enter Path" -DefaultText "C:\Service\tools"
|
|
|
}
|
|
|
+if ($inputname -eq $null -or $inputname -eq ""){
|
|
|
+ exit
|
|
|
+}
|
|
|
|
|
|
if ($outputname -eq $null -or $outputname -eq ""){
|
|
|
$outputname = Read-InputBoxDialog -Message "Output CSV file" -WindowTitle "Enter Path" -DefaultText "C:\Service\dirs.csv"
|
|
|
}
|
|
|
+if ($outputname -eq $null -or $outputname -eq ""){
|
|
|
+ exit
|
|
|
+}
|
|
|
|
|
|
-$FolderPath = Get-ChildItem -Directory -Path $inputname -Recurse -Force
|
|
|
-$Output = @()
|
|
|
-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
|
|
|
+function main {
|
|
|
+ $FolderPath = Get-ChildItem -Directory -Path $inputname -Recurse -Force
|
|
|
+ $Output = @()
|
|
|
+ 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 $outputname
|
|
|
+ $Output | Out-GridView -PassThru
|
|
|
}
|
|
|
-$Output | Export-Csv -Path $outputname
|
|
|
-$Output | Out-GridView -PassThru
|
|
|
+main
|