Get-WMIObject Win32_ComputerSystem UserName returns null for RDP user

Russell Ramey 26 Reputation points
2021-04-08T14:43:54.437+00:00

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 for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-04-09T03:31:16.68+00:00

    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 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.