General Learning Performance vCenter

Want to Change VM Component Protection Settings via PowerCLI? Now you can!

I had a VMware Senior Systems Engineer reach out to me yesterday asking on a customer’s behalf, if there were any PowerCLI cmdlets that could change VMCP settings.

*** If you are not familiar with VM Component Protection, I suggest you take a look at this blog post written by my co-worker Matt Meyer, which describes in detail what VMCP is and what each setting does: https://blogs.vmware.com/vsphere/2015/06/vm-component-protection-vmcp.html ***

I knew that we didn’t have any cmdlets for this yet so the next step for me was to jump into the vSphere Web Client to take a look at exactly which VMCP settings a user could set in the GUI.

To get to the VM Component Protection settings, right-click on a cluster and select ‘Settings’.

2015-10-28 (1)

Next, Select ‘vSphere HA’ and click ‘Edit’.

2015-10-28 (12)

You will need to ensure that vSphere HA is enabled to edit any further settings. Once enabled, you can select “Protect against Storage Connectivity Loss” under the Host Hardware Monitoring – VM Component Protection section. However, just enabling this is not quite enough. You will also need to expand the ‘Failure conditions and VM response’ section down below.

2015-10-28 (4)

Here you will see four options. If you haven’t yet read the referenced blog post above, I suggest that you take a look at it now to understand each of these settings. I will not go into it as it has already been documented. Just know, that these are the settings and the drop-downs have each option available.

2015-10-28 (5)

 

Ok, now that you’ve seen the VMCP settings, let’s get into the two advanced functions I created to work with it.

The first advanced function is called Get-VMCPSettings. The only parameter needed is –cluster. This can be passed either as a string, or as the cluster object itself:

$cluster = Get-Cluster LAB-CL

Get-VMCPSettings –Cluster $cluster

or

Get-VMCPSettings –Cluster LAB-CL

You will see all the associated information is returned in a neatly formatted output.

2015-10-28 (6)

If you plan on changing the settings, you will use the Set-VMCPSettings advanced function:

All the parameters in this function are required, however, to make it much easier for you, I’ve added all possible values for each parameter into the function, meaning, as you type the dash “-“ and hit ‘Tab’ it will auto-complete the parameter name. by pressing the spacebar and hitting the ‘Tab’ button again you will be able to tab through all possible values for that parameter. This makes using the function much easier as you don’t have to worry about memorizing the possible values, or potentially misspelling words.

You will see that the results are displayed once the function completes.

2015-10-28 (13)

You can always go and double-check the settings in the vSphere Web Client under the HA settings window.

2015-10-28 (11)

Want to give it a try?

You can grab this module in the VMware PowerCLI-Example-Scripts github repo HERE: https://github.com/vmware/PowerCLI-Example-Scripts/blob/master/VMCPFunctions.psm1