| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- param (
- [string]$inputname = '',
- [string]$outputname = ''
- )
-
- Add-Type -AssemblyName System.Windows.Forms
- function Read-InputBoxDialog([string]$Message, [string]$WindowTitle, [string]$DefaultText)
- {
- Add-Type -AssemblyName Microsoft.VisualBasic
- return [Microsoft.VisualBasic.Interaction]::InputBox($Message, $WindowTitle, $DefaultText)
- }
- 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
- }
- 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
- }
- main
|