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

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

  • Comments 9
  • Likes

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:

whoami 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Don't you think there should be a command; "Who-Who-WhoAreYou"?

  • @JRV LOL ... I like that, whoami ... whoareyou

  • @Ed - I can hear them now.

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

  • that won't work in powershell.

  • @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

    northwindtraders\edwilson

    PS C:\>

  • @n00b

    see above comment to aaa  

  • I think it's work in powershell 3 or better

  • 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:\windows\system32\whoami.exe. Whoami is not a PowerShell command. WHOAMI /ALL is very useful