Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

"Add-Content : Cannot bind argument to parameter 'Path' because it is null": error

$
0
0

I am getting the error on the code below:

$ServerList = Get-Content "C:\Users\munjanga\Desktop\Execute\Testing\servers.txt"

$ServerList

 

$Header="FolderPath,IdentityReference,AccessControlType,IsInherited,InheritedFlags,PropagationFlags"

 

Add-Content -Value $Header -Path $Output

 

Foreach  ($Server in $ServerList) {

    $output = "\\$server\C:\Users\munjanga\Desktop\Execute\Testing $server.output.csv"

    Del $Output -ErrorAction SilentlyContinue

 

    $RootPath ="\\$Server\C:\system.sav"

 

    $Folders = dir $RootPath -recurse | where {$_.psiscontainer -eq $true} -ErrorAction SilentlyContinue

 

    Add-Content -Value "$Header" -Path $Output

 

    Foreach ($Folder in $Folders){

 

        $ACLs = get-acl $Folder.fullname | ForEach-Object { $_.Access }

 

        Foreach ($ACL in $ACLs){

 

            $OutInfo = $Folder.Fullname + "," + $ACL.IdentityReference + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," + $ACL.InheritanceFlags + "," + $ACL.PropagationFlags

 

            Add-Content -Value $OutInfo -Path $output -ErrorAction SilentlyContinue

    ?    }

    }?

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles