Automating vSphere Replication Bandwidth Limits with PowerCLI

Chris Wahl · Posted on2014-08-272014-08-24

If you’re running vSphere Replication on vSphere 5.5 and also have access to the vSphere Distributed Switch (VDS) – this one’s for you. One of my pet peeves with vSphere Replication (VR) is that there is no inherent way to control or limit the replication bandwidth. There are often times where you might find it advantageous to throttle bandwidth – such as during a backup window or critical business hour.

The two major ways to exercise limits on replication outside of VR are:

Use Network IO Control (NIOC) on a VDS, specifically the vSphere Replication network resource pool

When someone has the VDS, I usually lean towards option 1. It’s simple to do and requires little fuss on the network. It’s also controlling traffic right at the source, since NIOC only affects outbound traffic. But what about controlling the limits programmatically? It stands to reason that you’d probably want to automate the controls to turn them on when needed and off when not, right? Maybe even have a VR limit based on some external trigger?

I wrote a little PowerCLI code that you can use as-is or plug into something else you’re working on. It’s available on GitHub here and I’ve also embedded the code below. Huge kudos to scripting MVP Luc Dekens for his contribution on the commented section when I pinged him on Twitter.