Skip to content

Get you User SID with PowerShell

Sometimes you might need to know the SID of your own Windows 10 User Account!

Since I migrated everything from Domain joined to native Azure Active Directory (AzureAD) joined, I need it more often.

You can use the “whoami” command to get it:

whoami /user

Get your SID with WHOAMI
Get your SID with WHOAMI

Here is a short PowerShell snippet that can be easily used within PowerShell functions or scripts:

(([Security.Principal.WindowsIdentity]::GetCurrent()).User.Value)

Get your SID with PowerShell
Get your SID with PowerShell

This snippet is nothing fancy, it uses the GetCurrent() of the plain .NET API to return WindowsIdentity objects.

The advantage of this is pretty easy to explain: If we use the plain .NET WindowsIdentity Classes, we don’t need any modules and it is simple, and fast!

This might become handy, if you need to add users as local admin via the EndpointManager or, like me, also use some tools that needs the SID for AzureAD users instead of the azuread\UPN format.

Published inPowerShell

Be First to Comment

    Leave a comment

    By posting a comment you consent that I store the submitted information as well as your anonymized IP address on my servers, under the terms of my Privacy Policy. Your email is never shared with anyone else.

    Required fields are marked *.