Press "Enter" to skip to content

Zerto Auto VM Protection v6 with PowerShell 6.0

Joshua Stenhouse 5

Script 3 in my blog series on scripting Zerto 6.0 with PowerShell 6.0 is Auto VM Protection from a CSV. When creating a Virtual Protection Group (VPG) workflow in order to protect VMs in Zerto, there is a minimum of 14 configuration items per VPG. This means that it takes at least 28 clicks to configure a VPG end to end with the standard options:

ZertoVPGWizard

Scale this out to 200 VPGs and you’ll have to click 5,600 times. 1,000 VPGs is 28,000 clicks. Furthermore, if you have automation workflows for creating new VMs, how are you going to protect them?

This is where scripting can help you, by programmatically creating VPGs and protecting one or multiple VMs. Click on the below link to download my script and example CSV:

ZertoAutoVMProtectionv6.zip

This script only runs on PowerShell 6.0 and is compatible with Windows, Linux, and it was tested on both Windows 10 and Ubuntu 16.04 with ZVR 6.0 Patch 2. Extract it to “C:\ZertoAutoVMProtectionv6\”, at the start of the script configure the $LogDataDir, $VPGList, $VMList, and $ZertoServer variables. The script uses 2 CSVs. One with a list of VPGs and the relevant settings, the 2nd with a list of VMs which VPG to protect them in. Edit the 2 CSVs with your VPGs and VMs to protect and run the script, you’ll be prompted for your Zerto credentials.

BulkVMProtectionUbuntuScreenshot

The VPG name in the VM CSV must be listed in the VPG CSV list. Multiple VMs per VPG are supported along with multiple VPGs, each of which must not already exist in the ZVM. I recommend only changing the below settings in the VPG CSV on your first run (as the others have requirements, listed in the script):

VPGName, RecoverySiteName, ClusterName, FailoverNetwork, TestNetwork, Datastore, JournalDatastore, vCenterFolder

Once you’ve protected your first batch of VMs there’s nothing stopping you populating the CSVs with new VMs as they are provisioned in your environment. One of Zerto’s largest customers does exactly this to fully automate protecting new VMs.

One final caveat I must disclose is that Zerto still doesn’t have any REST API calls for creating VPGs to and from Hyper-V, AWS, or Azure, so this script only supports VMware to VMware protection. If there was an API I could automate it, but alas there is not. If you feel strongly about this being a requirement, please be sure to bring it up with your account team and voice it at ZertoCON next week. I need more than me saying this isn’t enough! Happy scripting,

Joshua

  1. Jason Jason

    Is there an easy way to create the VPGs as paused on the initial creation so we do not kick off several hundred at once?

    • Alieu Alieu

      A possible option I think might be to do it in batches and possibly run them as a scheduled task at different times without having a need to pause kickoff.

  2. Alieu Alieu

    Very useful script works fine for zerto 7.5 as well. What is the best way to adapt it to allow multiple nic configurations for some vms. Or should one always configure a single failover and test nic and then edit the vpgs containing vms with multiple nics later before final cutover?

  3. J Tobleck J Tobleck

    Hi, do you have any plans to revise this for Zerto 7.5? I’m getting some errors on required fields trying it in 7.5. Thanks!

  4. Jodie R Jodie R

    This does work successfully with Zerto 7.5, thank you.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: