describe-instances --query "Reservations[].Instances[].InstanceId" --filter "Name=tag:Name,Values=Linux" --output text) echo $instanceId aws ssm start-session --target $instanceId --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["22"], "localPortNumber":["10022"]}' $instanceId=$(aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --filter "Name=tag:Name,Values=Linux" --output text) Write-output $instanceId aws ssm start-session --target $instanceId --document-name AWS-StartPortForwardingSession --parameters "portNumber=22, localPortNumber=10022" Windows - Powershell macOS - Terminal