wiki.getshifting.com

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


vscodetasks
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

vscodetasks [2025/06/01 11:59] – created - external edit 127.0.0.1vscodetasks [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://portal.azure.com/#view/Microsoft_Azure_PIMCommon/ActivationMenuBlade/~/aadgroup" Write-Host "Make sure you have activated the correct PIM group: https://portal.azure.com/#view/Microsoft_Azure_PIMCommon/ActivationMenuBlade/~/aadgroup"
-Write-Host "Login to azure (use 'az logout' in case of problems)+Write-Host "Login to azure - If the popup doesn't show please minimize the windows to expose the top-left corner of the screen-foregroundcolor blue 
-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 -SubscriptionId aa123456-a123-a123-a123-abcd12345678 +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 = 'C:\Users\sjoer\.ssh' 
-$knownHostsFile = 'known_hosts' 
-Write-Host "Rename and remove known_hosts file: $knownHostsPath\$knownHostsFile" 
-if (Test-Path $knownHostsPath\$knownHostsFile){ 
-    Get-ChildItem $knownHostsPath\$knownHostsFile | Rename-Item -NewName { $_.BaseName + (Get-Date -Format "yyyyMMdd-HHmm") + $_.Extension } -Verbose 
-    Get-ChildItem $knownHostsPath | Where-Object { ($_.CreationTime -lt $limit) -AND ($_.Name -like "$knownHostsFile*") } | Remove-Item -Force -Verbose 
-} 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." -foregroundcolor green Write-Host "Done, you are now in $($subscription.Subscription.Name). Use one of the other tasks to continue." -foregroundcolor green
vscodetasks.txt · Last modified: by sjoerd