喂。如果我运行此代码
$server = "."
$adsi = [ADSI]"WinNT://$server"
$adsi.psbase.children | where {$_.schemaClassName -match "user"} | select name, objectsid |Format-Table -auto
我以这种形式获得对象sid
1 5 0 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类相同的结果。提前致谢
答案 0 :(得分:1)
$adsi.psbase.children | where {$_.schemaClassName -match "user"} | foreach-object{
$account = New-Object Security.Principal.NTAccount $_.name
$account.Translate( [Security.Principal.Securityidentifier] ).Value
}