Powershell

How to find which user is logged into a remote computer with 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 a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He 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. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

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.