The Woo
The Woo

Reputation: 18645

PowerShell Get ACL For Folders In A Text File

I have a text file with the exact paths of the folders that I want to get permission information from, and I am trying to use PowerShell to get the information from each folder. I want to add the information to a text file, with a delimiter value of ":"

Can someone please tell me what I am doing wrong...

$FullList = Get-Content "C:\Temp\ListofFoldersToCheck.txt"

$DataOutFile = "C:\Temp\PermissionInformation.txt"

Foreach ($Folder in $FullList)
{
    $ACLs = get-acl $Folder.Fullname | ForEach-Object { $_.Access }

    Foreach ($ACL in $ACLs)
    {
        $DataOutInfo = $Folder.FullName + ":" + $ACL.IdentityReference
        Add-Content -Value $DataOutInfo -Path $DataOutFile
    }
}

It is returning the error message: Get-Acl: Cannot validate argument on parameter 'Path'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

The $FullList data is separated by new lines, if that makes any difference.

Please help, this is driving me insane...

Upvotes: 0

Views: 3060

Answers (1)

JPBlanc
JPBlanc

Reputation: 72610

Hey The Woo you miss something here :

$Folder is a string, not a FileInfo (you should use Get-Item for that), so you should begin by : get-acl $Folder and not get-acl $Folder.Fullname.

Then you should just write :

$ACLs = (get-acl $Folder).Access

Upvotes: 1

Related Questions