$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 = "\\C:\Users\munjanga\Desktop\Repositroy "$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
}
}
}
答案 0 :(得分:2)
此行中有一个格式错误的字符串文字:
$output = "\\C:\Users\munjanga\Desktop\Repositroy "$server.output.csv"
--^
上面指出的"
不应该存在。我想你打算写:
$output = "\\C:\Users\munjanga\Desktop\Repositroy\$server.output.csv"
字符串开头的双向前进也可能不正确。也许它应该删除:
$output = "C:\Users\munjanga\Desktop\Repositroy\$server.output.csv"