How do I get the current username in Windows PowerShell?

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

How do I get the current username in Windows PowerShell?

15条回答
  •  一整个雨季
    2020-11-28 02:07

    $username=( ( Get-WMIObject -class Win32_ComputerSystem | Select-Object -ExpandProperty username ) -split '\\' )[1]
    

    $username

    The second username is for display only purposes only if you copy and paste it.

提交回复
热议问题