James' website

This is a test website to try out GitHub and Git Bash

View My GitHub Profile

Using whoami

18 May 2025 - jhunter

Sources

whoami /?

Command

whoami

Definition

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.

Options

Example 1

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

Example 2

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