Get SID of user account with PowerShell

I was looking at this post that uses a bit of C# code to get the SID of a user account. A Powershell Script however is easier to run:

(new-object System.Security.Principal.NTAccount('DefaultAppPool')).Translate([System.Security.Principal.SecurityIdentifier]).Value

Then replace ‘DefaultAppPool’ with the account you want the SID of. Note that the square brackets […]s are like typeof(…) in C# while they’re also used to do a cast.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s