

Get-AzSubscription -SubscriptionName $subscriptionName -ErrorVariable subscriptionNotPresent -ErrorAction Silentl圜ontinue | Out-Null # Change the current context to the subscription holding the Azure Bastion host, if the subscription exists otherwise, exit the script foregroundcolor $foregroundColor1 $writeEmptyLine Without errors, it can take up to 19 minutes to complete" + $writeSeperatorSpaces + $currentTime)` Write-Host ($writeEmptyLine + "# Script started. Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings "true" | Out-Null # Remove the breaking change warning messages


$global:currenttime= Set-PSBreakpoint -Variable currenttime -Mode Read -Action # $bastionName -> Name of the Azure Bastion host # $subscriptionName -> Name of the subscription holding the Azure Bastion host \Switch-AzureBastion-Standard-SKU-to-Basic-SKU.ps1 sub-hub-myh-management-01 bas-hub-myh-01 \Switch-AzureBastion-Standard-SKU-to-Basic-SKU.ps1 First of all, set the context to the subscription holding the Azure Bastion host(s), and then run the following Azure PowerShell cmdlets: If you want to validate or know the Bastion SKU for your Bastion host before running the script and without opening the Azure Portal. If you are not running the script from Cloud Shell, don’t forget to sign in with the Connect-AzAccount cmdlet to connect your Azure account. Azure Az PowerShell module version 8.1.0 and Az.Network module version 4.18.1 are required.Keep in mind that only the Owner and the User Access Administrator built-in roles can create and delete resource locks. If you have a resource lock on the resource group holding the Azure Bastion host, remove it temporarily while running the script.The Azure Bastion host’s Public IP Address (PIP) must be located in the same resource group as your Azure Bastion host.

#BASTION MAIN WINDOWS#
Then run the script from Windows Terminal, Visual Studio Code, or Windows PowerShell.
#BASTION MAIN DOWNLOAD#
To use the script, copy and save it as Switch-AzureBastion-Standard-SKU-to-Basic-SKU.ps1 or download it from GitHub. Lock the Azure Bastion resource group with a CanNotDelete lock.Redeploy same Azure Bastion host with Basic SKU.Delete Azure Bastion host with Standard SKU.Store the specified set of Azure Bastion host tags in a hash table.Check if the Bastion resource group has a resource lock if so, exit the script.Save the Bastion host if it exists in the subscription as a variable and check if it uses the Basic SKU if so, exit the script, otherwise the script will continue.Remove the breaking change warning messages.To automate and speed up this process, I wrote the below Azure PowerShell script, which does all of the following: So, to switch a Standard SKU Azure Bastion host to the Basic SKU, you must delete and recreate that Bastion host. However, downgrading from the Standard SKU to the Basic SKU is not possible and not supported at the moment.
#BASTION MAIN UPGRADE#
If you want, you can take a look at it over here: Azure Bastion: Upgrade Basic SKU to Standard SKU with Azure PowerShell * In a previous blog post, I already wrote an Azure PowerShell script that upgrades a bastion host from the Basic SKU to the Standard SKU. These days, you can easily upgrade from the Basic SKU to the Standard SKU in the Azure Portal or with Azure PowerShell*.
