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.