I'm trying to do an audit of some folders. I need to get NTFS permissions of every folder listed in input file. I have a folderlist.txt with folder paths.
This is the script I have:
$InputFile = "C:\Folderlist.txt"
$OutputFile = "C:\FolderPermissions.csv"
$FolderList = Get-Content $InputFile
ForEach ($Folder in $FolderList)
{
$Permissions = (Get-ACL $Folder).access | ForEach-Object {$_ |
Add-Member -MemberType NoteProperty -Name Folder -Value $Folder}
$Report += $Permissions
}
$Report | Select-Object Folder,IdentityReference,FileSystemRights,IsInherited |
Where {$_.Folder -ne $Null -and $_.IdentityReference -like "HARRAHS*" -and $_.IsInherited -ne "TRUE"} |
Export-CSV $OutputFile -NoTypeInformation
but it does not give any output. I'm powershell noob, can someone please guide me and tell me what am I doing wrong? The output I need is basically name of the folder and groups and users with permissions. E.g.:
Folder Path IdentityReference AccessControlType
C:\Folder1\ DOMAIN\User1 Read
C:\Folder1\ DOMAIN\Group1 Write
C:\Folder2\ DOMAIN\User2 Modify
C:\Folder2\ DOMAIN\Group2 Full
Any help is greatly appreciated. Thanks a lot.