question

RussellRamey-7574 avatar image
0 Votes"
RussellRamey-7574 asked RussellRamey-7574 commented

Get-WMIObject Win32_ComputerSystem UserName returns null for RDP user

So I am writing a PowerShell script to pick up some info from domain machines and one of the things that I want to correlate with is logged on user. In theory that is

(Get-WmiObject -ComputerName $CompName -ClassName Win32_ComputerSystem).username

...and it works just fine for locally logged in users. HOWEVER, it returns null for an RDP logged in user and I can't find any other way to get that information.

Has anyone got a clue how to get that info for an RDP logged in User?

This is all Active Directory 2016 with Win 10 1909 or later clients





windows-10-generalwindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
1 Vote"
IanXue-MSFT answered RussellRamey-7574 commented

Hi,

You can try query user

 query user /server:$servername

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Very interesting. Tunnel vision - it never occurred to me.

*query* explicitly returns both active and disconnected RDP sessions,

I wish there was an equivalent PowerShell cmdlet that returned a PS object but this is very helpful.

Thank you








0 Votes 0 ·