VMware PowerCLI

The Best User Interface for your VMware Datacenter!

set-DrsClusterGroup enhancement to be able to add a VM to an empty VMgroup, the case when the last VM in the group is deleted from the vCenter inventory.

When the last VM in a VMgroup is deleted from the vCenter inventory, it's no longer possible to add a new VM to the group with set-DrsClusterGroup. Adding VMs is only possible if minimal 1 VM is already part of the group. Although it is possible via the vCenter/UI. It would be very helpfull if this would be possible from set-DrsClusterGroup.

  • Guest
  • Mar 17 2020
  • Planned
  • Attach files
  • MC Baaijen commented
    31 Mar 04:14pm

    Found that the below code makes it possible to add the first VM to an empty VM-group. Might be useful to add this method in de set-DrsClusterGroup code for first VM's!

    $spec = New-Object VMware.Vim.ClusterConfigSpecEx

    $spec.GroupSpec = New-Object VMware.Vim.ClusterGroupSpec[] (1)

    $spec.GroupSpec[0] = New-Object VMware.Vim.ClusterGroupSpec

    $spec.GroupSpec[0].Operation = 'edit'

    $spec.GroupSpec[0].Info = New-Object VMware.Vim.ClusterVmGroup

    $spec.GroupSpec[0].Info.Vm = New-Object VMware.Vim.ManagedObjectReference[] (1)

    $spec.GroupSpec[0].Info.Vm[0] = New-Object VMware.Vim.ManagedObjectReference

    $spec.GroupSpec[0].Info.Vm[0].Type = 'VirtualMachine'

    $spec.GroupSpec[0].Info.Vm[0].Value = 'vm-25'

    $spec.GroupSpec[0].Info.Name = 'ESX67VMs'

    $spec.DrsConfig = New-Object VMware.Vim.ClusterDrsConfigInfo

    $spec.DpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo

    $modify = $true

    $_this = Get-View -Id 'ClusterComputeResource-domain-c7'

    $_this.ReconfigureComputeResource_Task($spec, $modify)