windowspowershellscripting

How do I get the current username in Windows PowerShell?


How do I get the current username in Windows PowerShell?


Solution

  • I found it:

    [Environment]::UserName
    $Env:UserName
    

    There is also:

    $Env:UserDomain
    $Env:ComputerName