Powershell offers multiple ways to find sid details of a user account on the computer. You could fetch the sid information for a local or remote user through Powershell. If needed, you could draw up the user account to sid mapping for all the users on a local computer. For the uninitiated, sid is the acronym for security identifier on the computer.
This tutorial will focus on getting the sid for a user account on the local computer. We will look at four ways you can get the sid for user accounts on the local computer.
Find sid of all users using Get-LocalUser cmdlet in Powershell
Get-Localuser is one of the most efficient ways to find the security identifiers (sids) of all or one specific user on the computer. The command for finding the sid using Get-Localuser is given below for your ready reference:
get-localuser | Select name,sid
This command will map user accounts on a local computer to the corresponding sid or security identifier. The output of this command is shared below as as a screenshot.
Get-Localuser can also be used to find the sid of a specific user. The command to find the sid of a specific user account on the local computer is shared hereunder:
get-localuser -name ‘HP’ | Select name,sid
This command would fetch the name and sid of the login account ‘HP’ on the local computer. The exact output is displayed as a screenshot below.
Get sid of all users using the wmic command in Powershell
WMIC remains the quickest, simplest, and the most user-friendly command in Powershell. You could use the wmic command in Powershell to get the sid of all the local user accounts on a particular computer. The exact command to fetch the sid to user account mapping is shared below:
wmic useraccount get name, sid
The command output for this wmic command is shared below in the screenshot. You could run Powershell with elevated credentials to get this information of sid to user accounts’ mapping on the local computer.
You could qualify the wmic useraccount wmic command to a specific user or the logged on user.
To find the sid of a specific user account on a local computer, we will use the following command:
wmic useraccount where name=’username’ get name, sid
You will need to replace the username with the login name of the specific user account you need to fetch details of.
To find the details of the sid for a logged on user, we will use the following command:
wmic useraccount where name=’%username%’ get name, sid
%username% is the placeholder for the local user account that is logged on to the computer.
Find sid of user account using WMI Object in Powershell
WMI Object method can also be used to find the sid of a user account on the local computer. For WMI Object to fetch the sid or security identifier of all the user accounts on a local computer we will use the Win32_useraccount class. The exact command that created a mapping between the local user accounts and the corresponding sid is given below.
get-wmiobject Win32_useraccount | select name, sid
The command output of this WMI Object command is displayed below as a screenshot.
Find sid of user account using CIM Instance in Powershell
We can also use the CIM Instance method to find the sid of user accounts on a local computer in Powershell. The exact command to get the sid of user accounts through CIM instance is shared below:
get-ciminstance Win32_useraccount | select name, sid
The command output creates a mapping between user accounts and the corresponding security identifiers on the computer. The screenshot below captures the output of this command in Powershell.
In this Powershell tutorial, we have seen four ways to find security identifier or sid of user accounts on a local computer. You could get the sid of local user accounts using:
- Get-Localuser cmdlet
- WMIC command
- WMI Object method using Win32_useraccount class
- CIM Instance method using Wind32_useraccount class
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?
Rajesh Dhawan is a technology professional who loves to blog about smart wearables, Cloud computing and Microsoft technologies. He loves to break complex problems into manageable chunks of meaningful information.