Determining the SID for a Local User Account
Here’s a simple script that returns the SID for a local user named mozaid:
Determining the SID for an Active Directory User Account
You can use the exact same approach to determine an Active Directory SID as you do for local user SID; the only thing is to include both the domain (fabrikam) and the user name (mozaid):