View RDP Sessions for a Server and Logoff Remotely

Scenario: You want to view who is RDP’ed into a specific Server and then log off remotely specific sessions:

Scriptlet:

To View:
Invoke-Command -ComputerName “ExSrv1” -ScriptBlock { quser }

To LogOff:
Invoke-Command -ComputerName ‘ExSrv2’ -ScriptBlock { logoff 2 }


Leave a comment