I'm new to Powershell and I need to know how to list all permissions of a folder for a specific user. This is what I have discovered so far:
$ReferenceAccountName = 'DOMAIN\Username'
[string[]]$SearchDirectories
= @('X:\SomeDirectory', 'F:\AnotherDirectory')
foreach ($RootDir in $SearchDirectories) {
$DirACL = Get-Acl -Path $RootDir
foreach ($ACL in $DirACL.Access){
if ($ACL.IdentityReference -like $ReferenceAccountName){
Write-Output $RootDir
}
}
foreach ($Directory in (Get-ChildItem -Path $RootDir -Recurse | `
Where-Object -FilterScript {$_.Attributes `
-contains 'Directory'})){
$DirACL = Get-Acl -Path $Directory.FullName
foreach ($ACL in $DirACL.Access){
if ($ACL.IdentityReference -like $ReferenceAccountName){
Write-Output $Directory.FullName
}
}
} }
However, this does not return any value with the Write-Output command. Changing it to Write-Host didn't work as well. Am I missing some crucial parts?
I'm using Powershell V2.0