How do I get the current username in Windows PowerShell?

后端 未结 15 2727
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 01:35

How do I get the current username in Windows PowerShell?

15条回答
  •  抹茶落季
    2020-11-28 02:13

    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)
    

提交回复
热议问题