Reset a hanging RDP session using PowerShell Remoting

PS H:\> $cred = Get-StoredCredential -Target "VANLANDEGHEMB" #using PSModule "CredentialManager 2.0"
PS H:\> # Create a remote session to the server
PS H:\> enter-pssession -ComputerName MyServer -Credential $cred
[MyServer]: PS C:\> query session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>services                                    0  Disc
 console                                     1  Conn
 rdp-tcp#27        VANLANDEGHEMB            60  Active
 rdp-tcp                                 65536  Listen
[MyServer]: PS C:\> reset session 60 /v
Resetting session ID 60
Session ID 60 has been reset
[MyServer]: PS C:\>Exit-PSSession

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s