If you need to determine the user account that is logged into a computer with a known IP address or computer name you may use the following command. This command is confirmed to work with Windows 7 but should also work the same on Windows 8 +.
You will need to make sure the Windows Firewall on the remote computer is configured to allow access inbound for “Remote Administration (RPC)” and/or “Remote Service Management (RPC)”
Open the Command Prompt and run:
“wmic.exe /node:(computer name or IP address) computersystem get username”
If you are returned an error of RPC server unavailable make sure the Firewall is open as described above.