Virtually Sober

If there is free booze and Virtualization; I'm there!

Logging Zerto Sync States Using REST APIs & PowerShell

A few days ago a Zerto prospect reached out to me on LinkedIn with an interesting script request and there is nothing like a good challenge to get me motivated to pull out PowerShell ISE! With over 1000 VMs to protect their key requirement was to log the start and end time of initial syncs. While the ZVR GUI shows when a VPG was created, it doesn’t show when the initial sync finishes:

This is certainly an annoying omission and the lack of specific data points isn’t limited to just Zerto; how many other solutions do you use in your environment where you want to know/see something that just isn’t there for seemingly no logical reason? Of course, you could contact your vendor account manager, raise a feature request, wait 3-6 months and cross your fingers that it was even considered let alone in the product. Or you can use the REST APIs to get the data yourself, today, in minutes!

To begin I did what any PowerShell admin should do. Look at what existing example scripts I could leverage to solve this new challenge as quickly as possible. At first I thought of integrating a timer into a create VPG script, but this wouldn’t then work if the user created a VPG by hand and has all sort of parallelism complexities. Then I thought about all the other sync states you might want to log and this script jumped out as the most logical choice:

After cleaning it up, switching to JSON (can’t remember why I even used XML), adding in the new fields to log, and creating 2 functions to translate the current VPG statuses to a human readable format; I created a new script which gives you this handy CSV showing how long it took for the initial sync to complete:


You can change to filter only by VPGs that are not in a healthy protected state on line 352 as I did in the above example or leave at as default to see everything. The script auto creates a folder for each month and a CSV for each Zerto Organization (for cloud providers) and it should be scheduled to run every 1-5 minutes depending on how accurate you want to measure the sync states and timing.

Not only is this script useful for logging initial syncs you can keep it running for historical logging of RPOs, storage usage, bitmap syncs, delta-syncs, basically anything that is or isn’t healthy. To get you started download the example below and edit the variables on lines 30-34:

For simplicity, I’ve left the credentials in plain text as is the case in most examples. If you want to change this check out this handy blog post:

If you found this useful please share. Happy scripting,




Leave a Reply

%d bloggers like this: