Alex Rivera | Logout

How do I get the current username in Windows PowerShell?

Asked 2010-01-18T11:50:32.687
522

How do I get the current username in Windows PowerShell?

Edit
Report

1 Answer

62

I'd like to throw in the whoami command, which basically is a nice alias for doing %USERDOMAIN%\%USERNAME% as proposed in other answers.

Write-Host "current user:"
Write-Host $(whoami)
answered 2011-11-14T09:08:35.347

Your Answer