Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
powershell将objectsid转换为sid_Powershell - Fatal编程技术网

powershell将objectsid转换为sid

powershell将objectsid转换为sid,powershell,Powershell,你好。如果我运行这个代码 $server = "." $adsi = [ADSI]"WinNT://$server" $adsi.psbase.children | where {$_.schemaClassName -match "user"} | select name, objectsid |Format-Table -auto 我得到这个表单中的对象sid 150 0 0 0 0 5 21 0 0 0 138 93 63 151 163 49 215 2 60 164 164 50

你好。如果我运行这个代码

$server = "."
$adsi = [ADSI]"WinNT://$server" 
$adsi.psbase.children | where {$_.schemaClassName -match "user"} | select name, objectsid |Format-Table -auto
我得到这个表单中的对象sid

150 0 0 0 0 5 21 0 0 0 138 93 63 151 163 49 215 2 60 164 164 50 236 3 0 0


我想知道是否有可能将其转换为与win32_useraccount类相同的结果。提前谢谢

嗨,谢伊。非常感谢你。我正在寻找一种方法来找到管理员帐户的名称$server=“.”$adsi=[adsi]”WinNT://$server“$admin=$adsi.psbase.children |其中{$$$.schemaClassName-match“user”}}%{$account=New Object Security.Principal.NTAccount$\ name新对象PSObject-Property@{name=$\ name sid=$account.translate([Security.Principal.Securityidentifier]).Value}|?{$u.sid.endswith('-500')}{${$uu.name}}$admin只要我达到必要的最低分数,我就投你一票。再次感谢。请绑定到管理员帐户并获取其名称。在powershell v1中,您可能必须首先添加psbase($admin.psbase.name)$admin=[adsi]“WinNT://$server/administrator,user”$admin.name使用以下一行代码,您可以获得管理员帐户的名称和sid:$admin | select{n='name';e={${${n='name},@{n='sid';e={(New Object Security.Principal.NTAccount$\ name)。translate[Security.Principal.Securityidentifier]).Value}}再次感谢谢伊,祝贺你的博客非常有趣;)
$adsi.psbase.children | where {$_.schemaClassName -match "user"} | foreach-object{    
  $account = New-Object Security.Principal.NTAccount $_.name
  $account.Translate( [Security.Principal.Securityidentifier] ).Value
}