PowerShell: Active Directory User to SID and SID to User

I was recently asked to find the username associated with a particular Active Directory SID (technically I was given the RID).

This is actually pretty easy in PowerShell, and quite intuitive using basic AD cmdlets.

Get the user for a given RID:

Get-ADUser -Filter * | Select-Object -Property SID,Name | Where-Object -Property SID -like "*-6640"

Get the SID for a given user:

Get-ADUser -Identity ad.user | Select-Object -Property Name,SID
This entry was posted in PowerShell, Windows and tagged , , , , , , , . Bookmark the permalink.

One Response to PowerShell: Active Directory User to SID and SID to User

  1. Emmanuel says:

    Hi Robin,

    Get-ADUser -Identity S-1-5-21-2511372296-46634312-3923189056-2186

    Much faster :)

    If you need the SID portion, you can get it with :
    (Get-ADDomain).DomainSID

    So :
    Get-ADUser -Identity “$((Get-ADDomain).DomainSID.Value)-2186” is much more efficient in large environment :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s