Windows: Get a User’s SID – CMD & PowerShell

Any user, group or computer in Windows has a unique SID (security identifier) assigned.

The SIDs are used to control access to various Windows resources like files, registry keys, network shares, etc.

Below i will show you how to get the user’s SID and how to do the reverse SID lookup (get the user name by SID) using the Windows command prompt or PowerShell.

Cool Tip: How to determine whether the current user is a Domain User account or a Local User account! Read more →

Get a User’s SID using Windows CMD & PowerShell

Get the SIDs of the all local user accounts:

C:\> wmic useraccount get name,sid
- sample output -
Name                SID
admin               S-1-5-21-615456588-3658538152-758053764-1009
myUser              S-1-5-21-615456588-3658538152-758053764-1008

Get the SID of the current user:

C:\> whoami /user
- or -
C:\> wmic useraccount where name='%username%' get sid

Find the user’s SID by name:

C:\> wmic useraccount where name='<username>' get sid
- example -
C:\> wmic useraccount where name='myUser' get sid
- sample output -
SID
S-1-5-21-615456588-3658538152-758053764-1008

Find the user by SID (reverse SID lookup):

C:\> wmic useraccount where sid='<sid>' get name
- example -
C:\> wmic useraccount where sid='S-1-5-21-615456588-3658538152-758053764-1008' get name
- sample output -
Name
myUser
Was it useful? Share this post with the world!

3 Replies to “Windows: Get a User’s SID – CMD & PowerShell”

  1. Great! Thank you very much!

  2. what the hell does this article have to do with powershell?
    what a waste of time.

  3. i have used this one:

    get-wmiobject -Class win32_userprofile | select sid, localpath

Leave a Reply