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.