Hi,
I’m very new at Powershell, so please excuse the potentially basic question.
I’m trying to see the security permissions/access for selected folders, and the sub folders within them, and export them as a .csv . I found the following code online (please ignore the specific paths included):
$FolderPath = dir -Directory -Path "C:\Temp" -Recurse -Force
$Report = @()
Foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
foreach ($Access in $acl.Access)
{
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
Group or
User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Report += New-Object -TypeName PSObject -Property $Properties
}
}
$Report | Export-Csv -path "C:\temp\FolderPermissions.csv"
This seems to work well if I change the path in the first line, and the .csv output location for each folder.
However I was wondering if there was a way to speed this up? I have a .csv file of all the folder paths and corresponding output names. Eg. C:\example and ‘myexample’.
In an ideal world, it would go through each pair, look at all the folder permissions for the folders within the named folder path, then spit out a .csv with corresponding names in another folder. I imagine the way to do it is import the folder path/name .csv, create a variable then do a ‘for each’ type command, but I don’t know how to do it and integrate it into the above code.
Many thanks!