WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / vCenter Server High Availability (VCHA) PowerCLI 6.5 community module

vCenter Server High Availability (VCHA) PowerCLI 6.5 community module

12.08.2016 by William Lam // 15 Comments

As some of you may know, I have been spending some time with the new vCenter Server High Availability (VCHA) feature that was introduced in vSphere 6.5. In fact, I had even published an article a few weeks back on how to enable the new vCenter Server High Availability (VCHA) feature with only a single ESXi host which allowed me to explore some of the new VCHA APIs without needing a whole lot of resources to start with, obviously, you would not do this in production 🙂

For those of you who are not familiar with the new VCHA feature which is only available with the vCenter Server Appliance (VCSA), Feidhlim O'Leary has an excellent write up that goes over the details and even provides demo videos covering both the "Basic" and "Advanced" workflows of VCHA. I highly recommend you give his blog post a read before moving forward as this article will assume you understand how VCHA works.

In playing with the new VCHA APIs, I decided to create a few VCHA functions which I thought would be useful to have as a PowerCLI module for others to use and also try out. With that, I have published my VCHA.psm1 module on the PowerCLI Community Repo on Github which includes the following functions:

Name Description
Get-VCHAConfig Retrieves the VCHA Configuration
Get-VCHAClusterHealth Retrieve the VCHA Cluster Health
Set-VCHAClusterMode Sets the VCHA Cluster Mode (Enable/Disable/Maintenance)
New-VCHABasieConfig Creates a new "Basic" VCHA Cluster
Remove-VCHACluster Destroys a VCHA Cluster

As noted earlier, VCHA Cluster can be deployed using either a "Basic" or "Advanced" workflow. The VCHA PowerCLI module currently only implements the "Basic" workflow. For those interested in the Advanced workflow, you are more than welcome to extend the script but note that it does require leveraging additional VCHA APIs than the ones used in the Basic workflow. Make sure you also have PowerCLI 6.5 R1 installed before trying to use the module.

Here is a screenshot of my vSphere 6.5 environment which has a self-managed VCSA (which will be required for the Basic workflow) OR you can have management cluster that hosts the VCSA you wish to enable VCHA on as long as it is joined to the same SSO Domain. For management clusters that do not share the same SSO Domain with the VCSA that you want to enable VCHA on, then you will have to use the Advanced workflow. You must also enable SSH on the VCSA before attempting to configure VCHA or else you will run into an error. This is something VCHA itself requires and has nothing to do with the script, you will see this behavior regardless of using the UI or API. SSH can be disabled after VCHA is setup.

vcenter-high-availablity-apis-using-powercli-0
To create a new VCHA Cluster, we will use the New-VCHABasicConfig command and you will need to specify the following:

  • Name of VCSA VM
  • Name of the VCHA Network (Virtual Portgroup or Distributed Portgroup)
  • Active VCSA HA IP Address / Netmask
  • Passive VCSA HA IP Address / Netmask
  • Witness HA IP Address / Netmask
  • Name of the Passive and Witness vSphere Datastore to use
  • vSphere Credentials to the VCSA

Here is an example command for my environment:

New-VCHABasicConfig -VCSAVM "vcenter65-1" -HANetwork "DVPG-VCHA-Network" `
   -ActiveHAIp 192.168.1.70 `
   -ActiveNetmask 255.255.255.0 `
   -PassiveHAIp 192.168.1.71 `
   -PassiveNetmask 255.255.255.0 `
   -WitnessHAIp 192.168.1.72 `
   -WitnessNetmask 255.255.255.0 `
   -PassiveDatastore "vsanDatastore" `
   -WitnessDatastore "vsanDatastore" `
   -VCUsername "*protected email*" `
   -VCPassword "VMware1!"

Depending on your compute and storage resources, this can take some time while the Passive and Witness VCSA is being cloned from the Active VCSA. Once the operation has completed, you can refresh the vCenter HA tab in the vSphere Web Client and you should see that VCHA is now enabled as shown in the screenshot below.

vcenter-high-availablity-apis-using-powercli-2
Similarly to the UI, we can also retrieve the current configuration as well as health of the VCHA Cluster.

To get the VCHA Configuration, you can use the Get-VCHAConfig command.

vcenter-high-availablity-apis-using-powercli-3
To get the VCHA Cluster health, you can use the Get-VCHAClusterHealth command:

vcenter-high-availablity-apis-using-powercli-4
The VCHA Cluster can also be placed into different "Modes" such as Enabled, Disabled or Maintenance. To do so, you can use the Set-VCHAClusterMode which includes boolean flags for each of the modes. For example, if you wanted to disable the VCHA Cluster, you would run the following command:

Set-VCHAClusterMode -Disabled $true

vcenter-high-availablity-apis-using-powercli-5
To view the current VCHA Cluster Mode, you can simply use the Get-VCHAConfig command.

Finally, if you wish to destroy the VCHA Cluster, there is the Remove-VCHAConfig command which supports two additional flags. One that by-passes confirmation that you wish to destroy the VCHA Cluster (basically a safety protection) and the other whether or not to delete the VMs after the VCHA Cluster has been destroyed. By default, the VCHA APIs does not offer a native way of automatically deleting the VMs and if you have used the UI, you will see the UI adds this additional functionality which I have also done so in the VCHA module. If either flags are committed, then you will be prompted by the script.

Here is an example of automatically confirming to destroy the VCHA Cluster as well as deleting the VMs afterwards:

Remove-VCHAConfig -DeleteVM $true -Confirm:$false

vcenter-high-availablity-apis-using-powercli-6

More from my site

  • vCommunity "shorts" on their experiences w/the VCSA Migration
  • VCSA 6.5 CLI Installer now supports new ovftool argument pass-through feature
  • Updates to VMDK partitions & disk resizing in VCSA 6.5
  • Will I get Photon OS when I upgrade my VCSA 5.5/6.0 to VCSA 6.5?
  • How to deploy the vCenter Server Appliance (VCSA) 6.5 running on VMware Fusion & Workstation?

Categories // Automation, VCSA, vSphere 6.5 Tags // vcenter server appliance, VCHA, VCSA, vcva, vSphere 6.5, vSphere API

Comments

  1. *protectedJody Whitlock says

    02/02/2017 at 10:29 pm

    One thing I'm not finding in the docs, maybe due to lack of effort on my part, is wither or not the VCHA appliances need to all be on the same L2 subnet. I have a situation where I have a secondary data center with dark fiber and around 2ms latency so could this be done across the dark fiber and span L3 boundries?

    Reply
    • William Lam says

      02/02/2017 at 10:41 pm

      Please see https://pubs.vmware.com/vsphere-65/index.jsp?topic=%2Fcom.vmware.vsphere.avail.doc%2FGUID-9B176C8A-4EEE-4A28-A3C1-24656D6402CF.html

      Reply
  2. *protectedRick Smith says

    02/14/2017 at 10:37 am

    Is there a way to disable/remove VCHA from the CLI in vCenter? I am having an issue with vCenter and it keeps bouncing back and forth. I am unable to connect via PowerCLI because the HA is failing over before the services completely stop.

    Reply
    • William Lam says

      02/14/2017 at 12:27 pm

      If you're unable to connect to your VC, then using the VCHA PowerCLI Module will not help as both the CLI and UI rely on the APIs. I would strongly advise that you file an SR w/VMware GSS so they can help you troubleshoot and get your environment back to working order.

      Reply
    • *protectedTodd says

      03/22/2017 at 3:11 pm

      destroy-vcha. took me forever to find it, so I thought I'd share. It's documented here:
      https://pubs.vmware.com/vsphere-65/index.jsp?topic=%2Fcom.vmware.vsphere.avail.doc%2FGUID-FE5106A8-5FE7-4C38-91AA-D7140944002D.html

      Reply
  3. *protectedDavid Hocking says

    08/15/2017 at 2:52 pm

    Link to the module is broken I think, is it still available? Thanks

    Reply
    • William Lam says

      08/15/2017 at 8:44 pm

      It looks like they re-organized the Modules on the VMware Repo, I've just fixed the link

      Reply
  4. *protectedDavid says

    01/23/2018 at 1:49 pm

    What are the minimal permissions to disable/maintenance the VCHA?

    Reply
  5. *protectedSean says

    06/12/2018 at 5:09 am

    Hi
    The script has always worked for me very well, but recently we have had to redo the VCHA config, but when we run the script, we are getting the below error message which we never used to get before
    "The operation for the entity "Datacenters" failed with the following message: "Authenticity of the host's SSL certificate is not verified."

    Reply
    • *protectedPeter van de Velden says

      09/20/2024 at 8:13 am

      Hello Sean is you issue resolved and how? 🙂 we get the some error.

      Reply
  6. *protectedGerg says

    10/04/2019 at 7:41 am

    Hi Will,
    Really appreciate all the effort that goes into the blog and scripts.
    Just wondering if the script is working with vCenter 6.7 u2 / u3?
    Any plans to get the functions added into PowerCLI?
    Many thanks,
    Gerg

    Reply
  7. *protectedVinod says

    03/08/2021 at 9:20 am

    Great, is there any plan to add failover on this script ?

    Reply
    • *protectedSebastien Pomme says

      04/10/2021 at 2:03 am

      Yes it's possible (tested in 6.5 only) :

      Function Set-VCHAInitiateFailover {

      $vcHAClusterManager = Get-View failoverClusterManager
      Write-Host "Initiate VCHA Failover ..."
      $task = $vcHAClusterManager.initiateFailover_Task("True")
      $task1 = Get-Task -Id ("Task-$($task.value)")
      $task1 | Wait-Task
      }

      Reply
      • enomore+*protectedenomore says

        10/17/2023 at 8:44 am

        Thanks for posting. I'll try this.

        Reply
  8. *protectedmax says

    12/28/2023 at 5:36 pm

    how to initiate a failover using cmdlet? if the passive is the active node then I need a way to check and initiate a failover back to the primary vcsa.

    Reply

Thanks for the comment!Cancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • VCF 9.0 Hardware Considerations 05/30/2025
  • VMware Flings is now available in Free Downloads of Broadcom Support Portal (BSP) 05/19/2025
  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...