Display Windows Local user SID easy Command Line
To get the user SID for an active directory domain account of the logged in user use the simple whoami command.
The whoami command when run from a command prompt will display the currently logged in user. This command though not well known is often used by technicians who are remote controlling a desktop proving remote support and are working out an issue related to user accounts a or a user profile issue.
When working with profile issues, it's often necessary to know the SID of the user. The method that's simple and works to display the user SID is opening a command prompt and running the whoami command with a command line option /user as shown below:
c:\>whoami /user
Displays the results as shown in the image below.
To get the SID on a local user account on Windows desktop , not domain account, the following command will display that.
wmic useraccount where name='username' get sid
Use PowerShell to get SID of local user (replace USERNAME with the actual username)
Open a PowerShell window and prompt then run the following.
Get-LocalUser -Name $env:USERNAME | Select sid
Get Domain User or Group Name from SID
The following PowerShell command will display the account of a domain group or domain user from the SID . It will also look in deleted AD objects as well.
$SID = "S-1-5-21-xxxxxxx-xxxxxxx-xxxxxx-xxxx"
Get-ADObject -includeDeletedObjects -Filter * -Properties * | where{$_.objectSid -eq $SID}
The output of this command returned nothing, that let's us know there is no AD account , user or group, with that SID.
Here is one that was in Active Directory. Again , we use the same PowerShell command for users and Groups but the output results differs greatly as you can see. This object was found in Active Directory.
The command could also be run using a wildcard, an asterisk , in the SID to return all the accounts that begin with the same characters. Like this.
$SID = "S-1-5-21-*"
Whether your team or you are onsite or accessing systems remotely to manage and maintain, you can enhance your efforts easily and affordably. Run PowerShell commands to fix user accounts or look-up SIDs in Active Directory plus much more. Get the positive reaction and response from clients that you deserve with Online Remote Support Software. Access Server and desktop computers on physical or virtual PCs remotely. With full web based Software for Online Desktop Support screen-sharing sessions and file transfer are easy for providing better remote support and customer care.