Press "Enter" to skip to content

Zerto Recovery Plan v6 with PowerShell 6.0

Joshua Stenhouse 3

To celebrate the upcoming ZertoCON 2018 (05/21 Boston) I thought it was about time that I updated some of my most popular Zerto scripts. Most were written before the API authentication change of ZVR 5.0 U3, and with the release of both ZVR 6.0 and PowerShell 6.0, this gives me an opportunity to update to all the 6s! To keep things simple each new version will be labeled v6 so you can easily tell which version you need.

Over the course of the next 2 weeks in the build-up to ZertoCON, I’m going to release an updated script every other weekday. If you haven’t signed up for ZertoCON yet click on the link below:

ZertoCON2018_LOGO_onlight_50hWeb_horizontal_onWhite

To future proof my work each new script is ONLY compatible with PowerShell 6+ and has only been tested on ZVR 6.0, running from both Windows 10 and Ubuntu. Yes, you read that right, you can run all of them just as easily in Linux as you can Windows! Just be sure to change the default logging directory variables at the start of each to your Linux filesystem and you’re good to go. If you need help installing PowerShell in Linux I used this guide:

https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-powershell-core-on-linux?view=powershell-6

Just to re-state this clearly; DO NOT RUN THESE SCRIPTS IN ANYTHING BEFORE POWERSHELL 6.0 AS THEY WON’T WORK! This is primarily due to the new way Invoke-RestMethod handles certificate exceptions.

I’m going to start with the latest version of my most popular script; the Zerto Recovery Plan. Need to orchestrate the recovery of multiple VPGs in a set order with boot delays between each? This is the script you need! Want to script starting and stopping a failover test? Check. Want to prompt the user with questions and run external scripts like SRM? Got that too.

RecoveryPlanSimple

To download the scripts, click below:

ZertoRecoveryPlanv6.zip

Unzip the script to C:\ZertoRecoveryPlanv6\ or your chosen Linux directory. Update the variables at the start of the script to match your ZVM IP/hostname and the directory you chose to extract to.

Note 08/24/18: I’ve added a PowerShell v5 version into the zip file due to much demand.

You’ll now see 2 versions; Simple and Advanced. Both examples come with a pre-built CSV and the values allowed are detailed in the requirements at the top of each Run script. Configure the CSV with your VPG names and desired settings and then run your chosen script. The stop script will only stop a failover test, if you have initiated a failover then you need to let it run its course or manually intervene (I.E no commit policy).

Simple gives you the ability to specify VPG failover order, Zerto recovery settings, and a boot delay between each VPG in seconds. I recommend most users starting with this before progressing to advanced.

RecoveryPlanAdvanced

Advanced does all the above, plus adds user prompts, 3rd party scripts, and extra boot delays for script operations. Because it adds complexity I decided to break this out for only the people who wanted this extra functionality.

Note: When running both scripts using VPGs configured with the TEST action in the CSV (as opposed to FAILOVER), you’ll see that all the settings on commit policy and reverse protection are ignored as they are of no use.

I hope you found this useful. If so, please like and share. Happy scripting,

Joshua

  1. Tom Ellsworth Tom Ellsworth

    This is a gorgeous script. I really like the new ways of working with the API in the script and how much cleaner it looks. Thanks for doing this!

    I haven’t done much with 6.0 yet, but my understanding was that since it is an altogether different product and different exe, wouldn’t it be pretty easy to include some validation to check the version and instruct on how to get 6 installed if someone tries to run it in a 5.1 environment? I think with 6.1 they even have some portability features too. So, conceivably, you could run a 5.1 script that gets 6.1 portable and runs the script with no install?

    • Joshua Stenhouse Joshua Stenhouse

      Hey Tom. Thank you for the kind words and that’s a good idea. I’ll have a look into it! As a minimum you could add your own small validation with something like:

      $PSVersionMajor = $PSVersionTable.PSVersion.Major
      IF ($PSVersionMajor -lt 6)
      {
      “Not Running in at least PowerShell v6, exiting script in 3 seconds”
      sleep 3
      Exit
      }

      Do you think I should add this to all the new Zerto scripts just in case?

      • Tom Ellsworth Tom Ellsworth

        Personally, I’d say that’s a good idea just because I think the .NET Core and .NET Framework versions of scripts are going to be very divergent until some time has passed and we’re all comfortable with the differences. I’m betting it will become a common practice to differentiate scripts that are compatible for one or the other.

        Alternatively, the $PSVersionTable.PSEdition might be a better token. It’s “Desktop” for 5.x and “Core” for 6.x versions. (There’s apparently a core 5.0 product out there too for Nano server, which might cause you trouble on that previous statement.)

Leave a Reply to Joshua StenhouseCancel reply

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

Discover more from Virtually Sober

Subscribe now to keep reading and get access to the full archive.

Continue reading