MyITGuy
8/13/2016 - 1:09 PM

PowerShell: Current User / Domain / ComputerName

PowerShell: Current User / Domain / ComputerName

[Environment]::UserName
[Environment]::UserDomainName
[Environment]::MachineName

[System.Security.Principal.WindowsIdentity]::GetCurrent().Name

$env:UserName

Write-Host (& "$($env:windir)\system32\whoami.exe")

$(Get-WMIObject -class Win32_ComputerSystem | select username).username

#Set PowerShell Window Title
$host.UI.RawUI.WindowTitle = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name