Get SID of a local user
wmic useraccount where name='username' get sidFor example, to get the SID for a local user with the login name ‘John’, the command would be as below
wmic useraccount where name='John' get sidGet SID for current logged in user
To retrieve the SID for current logged in user we can run the below command. This does not require you to specify the user name in the command. This can be used in batch files which may be executed from different user accounts.
wmic useraccount where name='%username%' get sidGet SID for current logged in domain user
Run the command ‘whoami /user’ from command line to get the SID for the logged in user.
c:\>whoami /user USER INFORMATION ---------------- User Name SID ============== ============================================== mydomain\wincmd S-1-5-21-7375663-6890924511-1272660413-2944159 c:\>Get SID for the local administrator of the computer
wmic useraccount where (name='administrator' and domain='%computername%') get name,sidGet SID for the domain administrator
wmic useraccount where (name='administrator' and domain='%userdomain%') get name,sid