How do I get the current username in Windows PowerShell?

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

How do I get the current username in Windows PowerShell?

15条回答
  •  借酒劲吻你
    2020-11-28 01:57

    If you're used to batch, you can call

    $user=$(cmd.exe /c echo %username%)
    

    This basically steals the output from what you would get if you had a batch file with just "echo %username%".

提交回复
热议问题