Created
April 17, 2020 02:36
-
-
Save aetos382/0c6b0a6b5ca115ff8dde6b637f405f84 to your computer and use it in GitHub Desktop.
This file contains 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
function Start-AwsPortForwarding { | |
param( | |
[Parameter(Mandatory, Position = 0)] | |
[string] $TargetInstanceId, | |
[Parameter(Mandatory)] | |
[int] $RemotePort, | |
[Parameter(Mandatory)] | |
[int] $LocalPort, | |
[string] $ProfileName = 'default') | |
$paramJson = @{ portNumber = @([string] $RemotePort); localPortNumber = @([string] $LocalPort) } | ConvertTo-Json -Compress | |
$paramJson = $paramJson -replace '"', '\"' | |
aws ssm start-session --document-name AWS-StartPortForwardingSession --parameter $paramJson --target $TargetInstanceId --profile $ProfileName | |
} | |
function Start-AwsPortForwardingForRemoteDesktop { | |
param( | |
[Parameter(Mandatory, Position = 0)] | |
[string] $TargetInstanceId, | |
[int] $RemotePort = 3389, | |
[int] $LocalPort = 33890, | |
[string] $ProfileName = 'default') | |
$params = @{ | |
TargetInstanceId = $TargetInstanceId | |
RemotePort = $RemotePort | |
LocalPort = $LocalPort | |
ProfileName = $ProfileName | |
} | |
Start-AwsPortForwarding @params | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment