I have a user logged in via RDP with the username "hero", However when I Enter-PSSesssion
with that machine and run Get-WMIObject -class Win32_ComputerSystem | select username
I get this output:
username
--------
I have a user logged in via RDP with the username "hero", However when I Enter-PSSesssion
with that machine and run Get-WMIObject -class Win32_ComputerSystem | select username
I get this output:
username
--------
Here's an answer taken from here:
# replace $computer with your remote machine
$csvtxt=QWINSTA /SERVER:$computer|%{[string]::Join(',',$_.Split(' ',
[StringSplitOptions]::RemoveEmptyEntries))}
$csv=ConvertFrom-Csv $csvtxt
$csv
This parses the output from QWINSTA into a PSObject, from here you can do a:
$csv | Select USERNAME