PowerTip: Use a PowerShell command to get User Name and Domain

Summary: Use an easy command in Windows PowerShell to get userdomain\username.

Hey, Scripting Guy! Question How can I use a command in Windows PowerShell to get information about a current user in userdomain\username format?

Hey, Scripting Guy! Answer Use the WhoAmI command:


Comments (11)

  1. jrv says:

    @Ed – I can hear them now.

  2. Anonymous says:

    Whomi is a utility command that is included with Vista and later and can be installed on earlier systems.

    It does not require PowerShell. It is located at: c:windowssystem32whoami.exe.

    Whoami is not a PowerShell command.

    WHOAMI /ALL is very useful

  3. jrv says:

    Don't you think there should be a command; "Who-Who-WhoAreYou"?

  4. mredwilson says:

    @AAA I am not certain what you are doing wrong, but WhoAmi still works. I just verified it on my laptop. I opened PowerShell, typed WhoAmI and here are the results:

    PS C:> whoami


    PS C:>

  5. mredwilson says:


    see above comment to aaa  

  6. Anonymous says:

    I think it’s work in powershell 3 or better

  7. Ed Wilson says:

    @JRV LOL … I like that, whoami … whoareyou

  8. aaa says:

    bull###t, it doesn't return anything in Sep. 2013!

  9. n00b says:

    that won't work in powershell.

  10. Vidar Thomassen says:

    What about this one?

  11. Adam Carr says:

    Just as a side not whoami will strip out non standard characters that are valid in usernames. For example testİ will become testI and that wont resolve back to a valid logon.

Skip to main content