Hi LucD,
below is the script for all cluster VM to get removed from VM Overrides
$clusterName = 'cluster'
$cluster = Get-Cluster -Name $clusterName
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$cluster.ExtensionData.Configuration.DrsVmConfig |
ForEach-Object -Process {
$drsVM = New-Object VMware.Vim.ClusterDrsVmConfigSpec
$drsVM.Operation = [VMware.Vim.ArrayUpdateOperation]::remove
$drsVm.RemoveKey = $_.Key
$spec.DrsVmConfigSpec += $drsVM
}
$cluster.ExtensionData.ReconfigureComputeResource($spec,$true)
Now I am bit confused, with below code which you shared, i have folllow the same way but I am not sure about the $spec content how to create for specific host.
$esxName = 'MyESX'
Get-VMHost -Name $esxName | Get-VM |
Foreach-Object -Process {
# Same as with the cluster
}