Press "Enter" to skip to content

Zerto Auto VM Protection v6 with PowerShell 6.0

Joshua Stenhouse 0

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

Leave a Reply

%d bloggers like this: