asked on
$FolderPath = Get-ChildItem -Directory -Path "C:\temp" -Recurse -Force
$Output = @()
ForEach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Type'='Folder';'Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Output += New-Object -TypeName PSObject -Property $Properties
}
}
$FilesPath = Get-ChildItem -File -Path "C:\temp" -Recurse -Force
ForEach ($File in $FilesPath) {
$Acl = Get-Acl -Path $File.FullName
ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Type'='File';'Name'=$File.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Output += New-Object -TypeName PSObject -Property $Properties
}
}
$Output | Out-GridView
The only bit Im stuck with now is to test weather $Access.IdentityReference is in reference to a user or a group.