Created
May 1, 2019 16:49
-
-
Save heyjoeway/9e7f8ca5638e31c99d71def4edc0a449 to your computer and use it in GitHub Desktop.
RDP over SSH (Powershell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$rdpSourcePort="3389", | |
[string]$rdpDestPort="20000", | |
[string]$sshPort="22", | |
[string]$sshUri="" | |
) | |
$sshProcess = Start-Process "ssh" -ArgumentList "-fNTC -L 127.0.0.1:${rdpDestPort}:127.0.0.1:${rdpSourcePort} $sshUri -p $sshPort" -PassThru | |
Start-Process "mstsc" -ArgumentList "/v:127.0.0.1:${rdpDestPort}" -Wait | |
Stop-Process -Id $sshProcess.Id -Force | |
Wait-Process -Id $sshProcess.Id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment