Powershell

How to find which user is logged into a remote computer with powershell

As an administrator you may find yourself needing to see which user is logged into a remote workstation if you are trying to troubleshoot an issue or if you need to see for security reasons.  In our powershell series, we have already covered some very powerful things that powershell enables admins to do.  Once again we can pull out this powerful tool to find which user is logged into a remote workstation.

As we discussed in a previous post about powershell, it can interact with WMI to gather a wide range of information ab0ut a computer or user.  We are continuing on with that line of thought with determining the username of the remote workstation.  We pass the win32_computersystem to the get-wmiobject commandlet and then we select a sub component of that information by piping the select username parameter to the overall command.  So putting those things together we get the below syntax.

Powershell command syntax

get-wmiobject win32_computersystem -computername %computername% | select username

remoteuser1

 

You will need to have admin privileges on the target workstation to be able to read information from WMI.  The win32_computersystem contains a wealth of other information about the computer aside from the username.  As in the screenshot above, you can use the select * pipe instead of just selecting the username to see all the information that you can pull.

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.