Converting between SID and account name

In a previous post, I mentioned the need to convert between Windows SID and the account name. A little Google-ing helped me create the following little powershell script arose

    [string] $sid
$objSID = New-Object System.Security.Principal.SecurityIdentifier ( $sid )
$User = $objSID.Translate( [System.Security.Principal.NTAccount] )

Save that in a file (I called mine "account_from_sid.ps1"). Now, you can say "account_from_sid " and get an account name back. Handy!

No comments:

Post a Comment