PowerShell: 101-vm-secure-password

Very simple deployment of a Windows VM using password stored in Key Vault


This is an Azure quickstart sample PowerShell script based on ARM template 101-vm-secure-password  from the repository azure\azure-quickstart-templates .

This script allows you to deploy a simple Windows VM by retrieving the password that is stored in a Key Vault. Therefore the password is never put in plain text in the script, and it will deploy the following resources…

Key Vault reference


… and in-addition to it, just in-case if the deployment is not successful, then it will rollback the entire deployment.


If the specified resource group is already exist then the script will not continue with the deployment.


Deploy-AzResource.ps1 [-ResourceGroupName] <string> [-Location] <string> [[-DNSLabelPrefix] <string>] [[-WindowsOSVersion] <string>] [[-VMSize] <string>] [-KeyVaultName] <string> [-AdminUserName] <string> [<CommonParameters>]


I 💙 PS> $param = @{
>> ResourceGroupName = 'compute-rg'
>> Location = 'westus'
>> KeyVaultName = 'sgdhjk-kv'
>> AdminUserName = 'sysadmin'
>> }

I 💙 PS> .\Deploy-AzResources.ps1 @param


Deployment is successful!


    View the code in GitHub  
Last modified: 17 September 2020

Share it on     |   |   |   | 
comments powered by Disqus