$ RootPath =“K:\ FolderName”
$ Folders = dir $ RootPath -recurse |其中{$ _.psiscontainer -eq $ true}
foreach($文件夹中的$ Folder){$ ACLs = get-acl $ Folder.fullname | ForEach-Object {$ _.Access} Foreach($ ACL中的$ ACL) {
$objSID = New-Object System.Security.Principal.SecurityIdentifier($ACL.IdentityReference) // the above line gives an error $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) $objUser.Value $OutInfo = $Folder.Fullname + "," + $objUser.Value + "," + $ACL.AccessControlType + "," + $ACL.IsInherited + "," +
$ ACL.InheritanceFlags +“,”+ $ ACL.PropagationFlags Add-Content -Value $ OutInfo -Path $ OutFile}}
错误是
+ $objSID = New-Object <<<< System.Security.Principal.SecurityIdentifier($
ACL.IdentityReference)
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
Exception calling "Translate" with "1" argument(s): "The trust relationship bet
ween this workstation and the primary domain failed.