Advertisement
joedigital

ps-get ntfs perms-netwrix

Jun 13th, 2025
438
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $OutFile = "C:\Temp\Permissions.csv" # Insert folder path where you want to save your file and its name
  2. $RootPath = "\\Pdc\Shared" # Insert your share directory path
  3. $Header = "Folder Path,IdentityReference,AccessControlType,IsInherited,InheritanceFlags,PropagationFlags"
  4. # $Header = "Folder Path,IdentityReference,AccessControlType,IsInherited,InheritanceFlags,PropagationFlags,FilesystemRights"
  5. $FileExist = Test-Path $OutFile  
  6. If ($FileExist -eq $True) {Del $OutFile}  
  7. Add-Content -Value $Header -Path $OutFile  
  8. $Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $True}  
  9. foreach ($Folder in $Folders){
  10.    $ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access  }
  11.    Foreach ($ACL in $ACLs){
  12.    $OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference  + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags  
  13. #  If you need detailed file system rights in your report, add the following at the end of previous line:  
  14. # + "," + ($ACL.FileSystemRights -replace ',','/' )
  15.    Add-Content -Value $OutInfo -Path $OutFile  
  16.    }}
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement