Windows – How to get the current username in Windows PowerShell

powershellscriptingwindows

How do I get the current username in Windows PowerShell?

Best Answer

I found it:

$env:UserName

There is also:

$env:UserDomain
$env:ComputerName