PowerShell – retrieve logged on user and machine name

Another quick and simple and useful PowerShell script to retrieve remote machine name and currently logged on user on the remote computer.

$strComputer = "."
$Var =GWMI -Comp $strComputer -CL Win32_ComputerSystem
"Machine Name: " + $Var.Name + " User Name: " + $Var.UserName

 

 

Leave a Reply