Skip to content

Instantly share code, notes, and snippets.

@jreypo
Created May 29, 2025 20:45
Show Gist options
  • Select an option

  • Save jreypo/11ba4bae78d15351e96488757984e25a to your computer and use it in GitHub Desktop.

Select an option

Save jreypo/11ba4bae78d15351e96488757984e25a to your computer and use it in GitHub Desktop.
# Azure Bastion tunnel script (PowerShell version) by @jreypo
#
# Requires Azure CLI installed in your Windows machine
#
$rg = Read-Host "Enter resource group name"
$bastion = Read-Host "Enter Bastion name"
$vmname = Read-Host "Enter virtual machine name"
$resourceport = Read-Host "Enter remote resource port"
$port = Read-Host "Enter local port"
$vmid = az vm show --resource-group $rg --name $vmname --query id --output tsv
az network bastion tunnel --resource-group $rg --target-resource-id $vmid --resource-port $resourceport --port $port --name $bastion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment