我无法在Windows 7上使用PowerShell将我的SID转换为友好名称

时间:2014-02-11 21:16:32

标签: powershell

  

$ 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.

0 个答案:

没有答案