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:
Here is a short PowerShell snippet that can be easily used within PowerShell functions or scripts:
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