PowerShell - Get Current User
Published: Powershell Estimated reading time: ~1 minutes
# User Name Only
$(Get-WMIObject -class Win32_ComputerSystem | select username).username
[Environment]::UserName
$env:username
# Domain Name and User Name
$(whoami)
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# Domain
[Environment]::UserDomainName
# Machine Name
[Environment]::MachineName