user1342164
user1342164

Reputation: 1454

Get-Acl : Cannot validate argument on parameter 'Path'. The argument is null or empty

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

Answers (1)

user189198
user189198

Reputation:

You're missing a closing brace on the line (fixed):

$Folders = Get-ChildItem $Root | Where {$_.PSIsContainer } | select fullname;

Upvotes: 1

Related Questions