|

How To Use The Whoami Command In Windows (2027)

Whoami is a built-in Windows command that tells you which account you are using.

It can also list that account’s groups, privileges and security identifier.

This guide covers each switch Microsoft documents.

Table of Contents

Whoami quick answer

Type whoami in Command Prompt and press Enter to see the domain and user name of the account you are signed in with.

Add switches to see the account’s groups, privileges or security identifier.

GoalCommand
Current domain and user namewhoami
Name and security identifier (SID)whoami /user
Groups the user belongs towhoami /groups
Security privilegeswhoami /priv
Everything in the access tokenwhoami /all
User principal namewhoami /upn
Logon IDwhoami /logonid

What the whoami command does

Microsoft says whoami displays user, group and privilege information for the account currently signed in to the local system.

Run without parameters, it returns the current domain and user name.

Microsoft lists Windows 11 and Windows 10 among the systems it applies to.

Open Command Prompt and run it

  1. Select Start and type Command Prompt.
  2. Open the Command Prompt result.
  3. Type whoamiand press Enter.

The output looks like DOMAIN1\administrator, which is the example Microsoft shows.

Show your name and SID

The /user switch displays the current domain and user name plus the security identifier (SID).

whoami /user

Show your groups

The /groups switch displays the user groups to which the current user belongs.

whoami /groups

This helps you confirm whether your account is in a group such as the one you set up with a group command.

Show your privileges

The /priv switch displays the security privileges of the current user.

whoami /priv

Show everything in the access token

The /all switch displays all information in the current access token, including the user name, SIDs, privileges and groups.

whoami /all

Because the output is long, you can save it to a file, for example by adding > whoami.txt at the end of the command.

Show your name in other formats

SwitchWhat it shows
/upnThe user name in user principal name (UPN) format
/fqdnThe user name in fully qualified domain name (FQDN) format
/logonidThe logon ID of the current user
/claimsThe claims for the current user, such as claim name, flags, type and values

Microsoft says /upn, /fqdn and /logonid belong to the first syntax form and do not combine with the other switches.

Change the output format with /fo

The /fo switch sets the output format for /user, /groups, /claims, /priv and /all.

ValueOutput
tableColumn-formatted output with headers, and the default
listLabel and value pairs, one item per line
csvComma-separated values you can parse or import
whoami /groups /fo csv

Add /nh to hide the column header, which works only with the table and csv formats.

Which switch answers which question

QuestionSwitch
Which account am I using right now?No switch
What is my SID?/user
Which groups is my account in?/groups
What privileges does my account have?/priv
What is my UPN?/upn
What is my FQDN-format name?/fqdn
What is my logon ID?/logonid
Show me all of it/all

Pick the narrowest switch that answers your question, because /all prints a long list.

Combine switches in one command

The second syntax form lets you combine /user, /groups, /claims and /priv with /fo and /nh.

The command below shows your name with its SID and your groups together.

whoami /user /groups

Add /fo list if you prefer label and value pairs, one item per line.

whoami /user /groups /fo list

Save the output to a file

You can redirect the output of any whoami command into a text file using the greater-than sign, the same technique Microsoft shows for long gpresult output.

  1. Open Command Prompt.
  2. Type whoami /all > whoami.txtand press Enter.
  3. Open whoami.txt from the folder shown at the prompt.

The file is saved in the folder the Command Prompt window is currently in.

How to read the basic output

Microsoft’s example output for plain whoami is DOMAIN1\administrator.

The part before the backslash is the domain, and the part after it is the user name.

PartExampleMeaning
Before the backslashDOMAIN1Domain
After the backslashadministratorUser name

Windows versions

Microsoft’s current page says whoami applies to Windows 11, Windows 10 and several Windows Server versions.

Its older archived page, last updated in 2016, lists Windows versions back to Windows XP and does not mention the /claims switch.

So /claims is documented only on the current page, and you should expect the other switches on any recent Windows PC.

All whoami parameters

ParameterWhat it does
/upnUser name in UPN format
/fqdnUser name in FQDN format
/logonidLogon ID of the current user
/userDomain, user name and SID
/groupsGroups of the current user
/claimsClaims for the current user
/privSecurity privileges
/fo formattable, list or csv output
/allAll information in the access token
/nhSuppresses the column header
/?Help

Syntax forms

FormCommand
Name formatswhoami [/upn | /fqdn | /logonid]
Selected detailswhoami {[/user] [/groups] [/claims] [/priv]} [/fo format] [/nh]
Everythingwhoami /all [/fo format] [/nh]

You can combine /user, /groups, /claims and /priv in one command, as the second form shows.

When whoami helps

  • Checking which account a Command Prompt window is running as.
  • Finding your SID for a command or support request.
  • Checking which groups your account is in.
  • Reviewing the privileges your account has.

If you need to change an account or its groups, see our Net User command guide and our Net Localgroup command guide.

To see which Group Policy settings apply to you, read our Gpresult command guide.

Our Tasklist and Taskkill guide covers another everyday command-line tool.

Sources

Microsoft Learn: whoami.

Microsoft Learn: Command-Line Syntax Key.

Leave a Reply

Your email address will not be published. Required fields are marked *