2015年10月20日 星期二

get sid windows7

wmic useraccount where name='administrator' get sid




Get SID of a local user
wmic useraccount where name='username' get sid

For 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 sid

Get 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 sid

Get SID for current logged in domain user

Run the command ‘whoami /user’ from command line to get the SID for the logged in user.
 Example:
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,sid

Get SID for the domain administrator
wmic useraccount where (name='administrator' and domain='%userdomain%') get name,sid

沒有留言:

張貼留言