Integrating WhoAmI Into PowerShell
There is a cool little tool called whoami.exe which is part of Windows ever since Windows Vista. Since it can provide results not just in plain text but also as comma separated values, it is very easy to integrate into PowerShell. For example, to find out the groups your user account is member of, try this simple line:
PS> whoami /groups /fo csv | convertfrom-csv
Group Name Type SID
---------- ---- ---
Everyone Well-known group S-1-1-0
BUILTIN\Administrators Alias S-1-5-32-544
BUILTIN\Users Alias S-1-5-32-545
NT AUTHORITY\INTERA... Well-known group S-1-5-4
CONSOLE LOGON Well-known group S-1-2-1
NT AUTHORITY\Authen... Well-known group S-1-5-11
NT AUTHORITY\This O... Well-known group S-1-5-15
LOCAL Well-known group S-1-2-0
NT AUTHORITY\NTLM A... Well-known group S-1-5-64-10
Mandatory Label\Med... Label S-1-16-8192
ReTweet this Tip!