View Only
  • 1.  Creating Empty Cluster Host and Guest Groups

    Posted Jul 08, 2019 03:20 PM

    I'm working on a script to pre-build several clusters. In the past, I've created groups and rules via PoweCLI for existing clusters, so there are hosts and guests available. What I'm trying to do now, is create the groups (and then the rules) for an empty cluster that doesn't have any hosts or guests.

    Is it possible to create an empty host and/or guest group? I know that you can't do it in the UI, nor can you remove the last member from one of the groups. I'd have thought that there might be some PowerCLI magic to create empty groups, but I can't seem to find anything (and I'm just back from vacation, so my google-fu should be strong today, but alas, it seems not).

    I could create a virtual ESXi host on our test clusters, and add it to the cluster I'm building, and do the same with a Linux guest, but it seems messy, and it's a manual process to remove it at the end of the day when there are 'real' hosts and guests in the cluster, which is what I'm trying to get away from here.

    Does anyone have any pointers or suggestions?



  • 2.  RE: Creating Empty Cluster Host and Guest Groups

    Posted Jul 08, 2019 03:27 PM

    And it looks like the answer is....

    Create a DRScluster group for vm with no vm

    Off to try it, but it looks like LucD to the rescue (again).

    My search-fu IS weak today....


  • 3.  RE: Creating Empty Cluster Host and Guest Groups
    Best Answer

    Posted Jul 08, 2019 03:42 PM

    Yes, you can, but you will need to use the API method.

    Something like this for example

    $dcName = 'MyDC'

    $clusterName = 'TestCluster'

    $ruleName = 'Rule1'

    $vmGroupName = 'VmGroup1'

    $hostGroupName = 'HostGroup1'

    $dc = Get-Datacenter -Name $dcName

    $cluster = New-Cluster -Name $clusterName -Location $dc -DrsMode FullyAutomated -DrsEnabled -HAEnabled

    $spec = New-Object VMware.Vim.ClusterConfigSpecEx

    $groupVM = New-Object VMware.Vim.ClusterGroupSpec

    $groupVM.Info = New-Object VMware.Vim.ClusterVmGroup

    $groupVM.Info.Name = $vmGroupName

    $spec.GroupSpec += $groupVM

    $groupHost = New-Object VMware.Vim.ClusterGroupSpec

    $groupHost.Info = new-object VMware.Vim.ClusterHostGroup

    $groupHost.Info.Name = $hostGroupName

    $spec.GroupSpec += $groupHost

    $rule = New-Object VMware.Vim.ClusterRuleSpec

    $rule.Operation = [VMware.Vim.ArrayUpdateOperation]::add

    $rule.Info = New-Object VMware.Vim.ClusterVmHostRuleInfo

    $rule.Info.Name = $ruleName

    $spec.RulesSpec += $rule

    $cluster.ExtensionData.ReconfigureComputeResource($spec, $true)


    Was it helpful? Let us know by completing this short survey here.

  • 4.  RE: Creating Empty Cluster Host and Guest Groups

    Posted Jul 08, 2019 04:59 PM


    Thanks very much, that is absolutely perfect. Works like a charm. I'll wrap it in a function call, and move on to the net part. :smileyhappy:

    Thanks again.