vscodetasks
Differences
This shows you the differences between two versions of the page.
vscodetasks [2025/06/01 11:59] – created - external edit 127.0.0.1 | vscodetasks [2025/09/21 09:38] (current) – [Example: Start a connection to a Azure Jumpbox through a Bastion] sjoerd | ||
---|---|---|---|
Line 122: | Line 122: | ||
<code powershell> | <code powershell> | ||
Write-Host "Make sure you have activated the correct PIM group: https:// | Write-Host "Make sure you have activated the correct PIM group: https:// | ||
- | Write-Host "Login to azure (use 'az logout' | + | Write-Host "Login to azure - If the popup doesn't show please minimize the windows to expose the top-left corner |
- | # Using az login because Connect-AzAccount opens login dialog in the background | + | # We need to use the azure cli as creating the tunnel to the jumpbox will only work with the azure cli |
- | # Connect-AzAccount | + | az logout |
- | az login | + | # Disable the subscription selector feature as well as sign in with WAM |
+ | az config set core.login_experience_v2=off | ||
+ | az config set core.enable_broker_on_windows=false | ||
+ | az login --tenant 7e4an71d-a123-a123-a123-abcd12345678 | ||
Write-Host "Set subscription to hub subscription which has the bastion" | Write-Host "Set subscription to hub subscription which has the bastion" | ||
- | Set-AzContext -Subscription aa123456-a123-a123-a123-abcd12345678 | Out-Null | ||
az account set --subscription aa123456-a123-a123-a123-abcd12345678 | az account set --subscription aa123456-a123-a123-a123-abcd12345678 | ||
- | # Remove the known hosts file, these are environment specific | ||
- | $daysToKeepKnownHosts = 28 | ||
- | $limit = (Get-Date).AddDays(-$daysToKeepKnownHosts) | ||
- | $knownHostsPath = ' | ||
- | $knownHostsFile = ' | ||
- | Write-Host " | ||
- | if (Test-Path $knownHostsPath\$knownHostsFile){ | ||
- | Get-ChildItem $knownHostsPath\$knownHostsFile | Rename-Item -NewName { $_.BaseName + (Get-Date -Format " | ||
- | Get-ChildItem $knownHostsPath | Where-Object { ($_.CreationTime -lt $limit) -AND ($_.Name -like " | ||
- | } else { | ||
- | Write-Host "The file $knownHostsPath\$knownHostsFile does not exist." | ||
- | } | ||
$subscription = Get-AzContext | $subscription = Get-AzContext | ||
Write-Host "Done, you are now in $($subscription.Subscription.Name). Use one of the other tasks to continue." | Write-Host "Done, you are now in $($subscription.Subscription.Name). Use one of the other tasks to continue." |
vscodetasks.txt · Last modified: by sjoerd