How do I get the SID value from whoami /all? RRS feed

  • Question

  • I have tried whoami /all | Select-String -Pattern 'SID' and it did not work well, it returns the actual SID string. Any suggestions?
    Monday, December 23, 2019 7:05 AM

All replies

  • Hi,

    Not sure which value you’re expecting? The whoami /all command should return the username and the SID of the username.

    You can also use for example:

    WMIC useraccount get name,sid

    Best regards,

    Blog: https://thesystemcenterblog.com LinkedIn:

    Monday, December 23, 2019 7:17 AM
  • This is how to get the current users SID string.

    (Get-CimInstance Win32_UserAccount -Filter "Name = '$env:USERNAME'").SID

    If you want a true SID object then create one:

     $sidstr = (Get-CimInstance Win32_UserAccount -Filter "Name = '$env:USERNAME'").SID
     $sid = [System.Security.Principal.SecurityIdentifier]$sidstr


    Monday, December 23, 2019 7:47 AM
  • That's exactly what I was looking for. Thank you!
    Monday, December 23, 2019 8:15 AM
  • That's exactly what I was looking for. Thank you!

    What was exactly what you were looking for? Mark the answer so others will know what worked for you.


    Monday, December 23, 2019 8:45 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, December 26, 2019 8:24 AM
  • You can get the sid's from get-localuser too.

    Thursday, December 26, 2019 7:16 PM