none
Power Shell Script to add list of VMs to existing Azure recovery vault and backup policy RRS feed

  • Question

  • Hi All,

    if you know, kindly share  a powershell script (AzureRM) to add list of VMs to existing Azure recovery vault and backup policy.

    Thank You,

    Rocky

    Wednesday, September 11, 2019 6:03 PM

All replies

  • Hi Rocky,

    The relevant PowerShell actions can be found here.

    So assuming you have the backup policy and the VM in place, use something like below. Do note this assumes your VM is non-encrypted. If the VM is however encrypted have a look at the previous article because you'll need to provide the backup service access to the key vault:

    $pol = Get-AzRecoveryServicesBackupProtectionPolicy -Name "YourExistingPolicy"
    
    ForEach ($vm in Get-Content "yourvmlist.txt")
    {
    Enable-AzRecoveryServicesBackupProtection -Policy $pol -Name "$vm" -ResourceGroupName "YourResourceGroup"
    }



    ---On the road to MVP---


    • Edited by Gijs Kerstens Thursday, September 12, 2019 7:39 AM Modified script for "list of VMs"
    Thursday, September 12, 2019 7:35 AM