Reputation: 1454
I am trying to run the code below but I am getting the error Get-Acl : Cannot validate argument on parameter 'Path'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. Any idea what is wrong?
$Root = "\\server\share"
$Results = @()
$Folders = Get-ChildItem $Root | Where {$_.PSIsContainer | select fullname
Foreach ($Folder in $Folders) {
$ACL = Get-Acl $Folder.FullName
Foreach ($Group in $ACL.Access) {
If ("$($Group.IdentityReference)" -like "*-W") {
$Results += New-Object PSObject -Property @{Folder=$Folder.FullName;Group=$Group.IdentityReference;Members=[string]$(Get-ADGroupMember $($Group.IdentityReference -split "\\")[1] | Foreach {$_.Name})}
}
}
}
}
$Results | Export-csv c:\pathto\file.csv -NoType
Upvotes: 0
Views: 7071
Reputation:
You're missing a closing brace on the line (fixed):
$Folders = Get-ChildItem $Root | Where {$_.PSIsContainer } | select fullname;
Upvotes: 1