This is a test website to try out GitHub and Git Bash
18 May 2025 - jhunter
whoami /?
whoami
This handy command shows you show the current user is.
It is great for using in a script, mostly when I want to see what rights the current user has.
/user
shows the user domain name and SID./groups
show the groups to which a user is a member./upn
only for a user in a domain, this option shows the user’s principal name./fo
lets you specify the output format, including csv
and table
.I like to get data into a powershell object a quickly as possible so I can select and sort objects the way I’d like.
For this task I convert the original whoami data into csv data; then I can convert the csv data into a powershell object with convertfrom-csv
.
$whoami = whoami /user /fo csv | convertfrom-csv
Sometimes I want to see if the current user actually got added to some or other AD group.
$groups = whoami /groups /fo csv | convertfrom-csv