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
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.