How do I get the current username in Windows PowerShell?

Thomas Bratt picture Thomas Bratt · Jan 18, 2010 · Viewed 609.8k times · Source

How do I get the current username in Windows PowerShell?

Answer

Thomas Bratt picture Thomas Bratt · Jan 18, 2010

I found it:

$env:UserName

There is also:

$env:UserDomain
$env:ComputerName