Skip to content

Instantly share code, notes, and snippets.

@heyjoeway
Created May 1, 2019 16:49
Show Gist options
  • Save heyjoeway/9e7f8ca5638e31c99d71def4edc0a449 to your computer and use it in GitHub Desktop.
Save heyjoeway/9e7f8ca5638e31c99d71def4edc0a449 to your computer and use it in GitHub Desktop.
RDP over SSH (Powershell)
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