I have the following code that exports to a CSV file the folder permissions from a root path:
$RootPath = "\\R9N2WRN\Test Folder"
$OutFile = "C:\CodeOutput\Permissions.csv"
$Header = "Folder Path,IdentityReference"
Del $OutFile
Add-Content -Value $Header -Path $OutFile
$Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true}
foreach ($Folder in $Folders)
{
$ACLs = get-acl $Folder.fullname |
ForEach-Object { $_.Access } |
Where {$_.IdentityReference -notlike "*BUILTIN*" -and $_.IdentityReference -notlike "*NT AUTHORITY*"}
Foreach ($ACL in $ACLs)
{
$OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference
Add-Content -Value $OutInfo -Path $OutFile
}
}
The output file has the column headings "Folder Path" and "IdentityReference", and as I want to run this script on multiple root paths, is there a way to get rid of those column headings from being sent with the output to CSV file?