Hello,
I have a situation where I have to configure HA, monitoring, etc. for a specific set of VMs in a cluster. These VMs must have VM overrides configured differently compared to the rest of the cluster. I know how to perform it manually, but I have to re-create the same procedure in PowerCLI and I'm not exactly sure on how to apply the VM overrides to the VMs and not to the whole cluster.
For now i have written the following:
$vms = Get-VM -name <name>
ForEach ($vm in $vms){
$spec = New-Object WMware.Vim.ClusterConfigSpecEx
$spec.dasVmConfigSpec = New-Object VMware.Vim.ClusterDasVmConfigSpec[] (1)
$spec.dasVmConfigSpec[0] = New-Object VMware.Vim.ClusterDasVmConfigSpec
$spec.dasVmConfigSpec[0].operation = "add"
$spec.dasVmConfigSpec[0].info = New-Object VMware.Vim.ClusterDasVmConfigInfo
$spec.dasVmConfigSpec[0].info.key = New-Object VMware.Vim.ManagedObjectReference
$spec.dasVmConfigSpec[0].info.key.type = "VirtualMachine"
$spec.dasVmConfigSpec[0].info.key.value = $vm.ExtensionData.MoRef.Value
$spec.dasVmConfigSpec[0].info.RestartPriority = "medium"
$spec.dasVmConfigSpec[0].info.PowerOffOnIsolation = $True"
$spec.dasVmConfigSpec[0].info.dasSettings = New-Object VMware.Vim.ClusterDasVmSettings
$spec.dasVmConfigSpec[0].info.dasSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings
$spec.dasVmConfigSpec[0].info.dasSettings.vmComponentProtectionSettings = New-Object VMware.Vim.ClusterVmComponentProtectionSettings
... Setting all the values for Component Protection and VM Monitorig ...
Now, near the end of the ForEach loop, I'm not sure on how to apply the created $spec configuration object to the $vm. Can it be done by something like this:
$_this = Get-View -Id $vm.VMHost.Parent.Id
$_this.ReconfigureComputeResource_Task($spec, $true)
And for ReconfigureComputeResource_Task, there are two parameters, but what does the 2nd parameter ($true) do?
If anyone could help, it would be much appreciated.