Convert System.Byte[] SID to readable SID


Today, I’ll show you a nice trick for those who don’t have the pleasure of the Active Directory Web Services with the Active Directory PowerShell module.

To query a AD, without the module, you need to use [ADSI] or [ADSISeacher] object type like that :


Now, imagine you need to retrieve the SID of that user :


It isn’t a readable SID. If you pipe that into “Get-Member”, you’ll find out why :


To get a usable and readable SID, you need to to something like that :


(New-Object -TypeName System.Security.Principal.SecurityIdentifier -ArgumentList $(([adsi]"LDAP://CN=Administrator,CN=Users,DC=D2K12R2,DC=local").objectsid), 0).value

Here is the technical documentation for that type of object.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.