Featured image of post Get you User SID with PowerShell

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`

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


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.