Account SIDs revisited

Uncategorized

I realised there is an easier way to get the data

function get-SID {
param (
 [string]$computername = $env:COMPUTERNAME
)
Get-WmiObject -Class Win32_AccountSID -ComputerName $computername |
foreach {
 $exp = "[wmi]'" + $($_.Element) + "'"
 Invoke-Expression -Command $exp |
 select Domain, Name, SID, LocalAccount
}
}

Use the wmi type accelerator with the path from the Element and you can just select the data you want.  As a bonus you can discover if the account is local or not

Comments are closed.