<< Back to Script Library

Get user’s SID

This script gets the user SID for the current username. If the same name exists in both the local computer and the domain, both SIDs will be returned.
Version: 2.1.2
Created: 2017-01-26
Modified: 2021-01-11
Creator: Sebastien Le Gonidec
Downloads: 960
Tags: security SID
The Script Copy Script Copied to clipboard
## win32_useraccount WMI class found to be very slow
## wmic useraccount where name='%username%' get sid

(New-Object System.Security.Principal.NTAccount("$env:userdomain\$env:username")).Translate([System.Security.Principal.SecurityIdentifier]).value