Hi Guys,
I am able to check VM Overrides Rule using the powercli commands and i need to disable them but not able to find the powercli command would appreciate if someone help here ?
Below commands to check-
Get-VM | Where-Object {$_.DrsAutomationLevel -eq "Disabled"}
and set this is the command Set-VM -DrsAutomationLevel Disabled
what is the command to disable above configuration?
Thanks
You could do something like this
@nmbgdc wrote:
I am looking for either to remove the vm from the list or remove the full list.
yes you understand correct.
$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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So what is the actual question?
The Set-VM cmdlet is the one to use with the DrsAutomationLevel parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Sorry for the confusion, I want to remove the overrides tick mark from again the DRS Automation level, below is the screenshot for your reference, is there any powercli command to remove the tick mark ?
Just to make sure I understand it correctly, you want to remove the VM from the Overrides list?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am looking for either to remove the vm from the list or remove the full list.
yes you understand correct.
You could do something like this
@nmbgdc wrote:
I am looking for either to remove the vm from the list or remove the full list.
yes you understand correct.
$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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, It works.
Hi LucD,
Your below code works and it remove all the VMs from the Overrides List, but I have got another use case I want to remove the few VM's running on specific host from the cluster VM overrides List is it possible ? if yes can you share the powershell commands..
$cluster = Get-Cluster -Name $cluster_Name
$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) >$null
Thanks
You would need to select the VMs running on that host.
The rest is the same as with the cluster
$esxName = 'MyESX'
Get-VMHost -Name $esxName | Get-VM |
Foreach-Object -Process {
# Same as with the cluster
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your reply,
This is how I tried this code but its giving the error..
Get-VMHost 192.168.200.42 | Get-VM |
>> ForEach-Object -Process {
>> $drsVM = New-Object VMware.Vim.ClusterDrsVmConfigSpec
>> $drsVM.Operation = [VMware.Vim.ArrayUpdateOperation]::remove
>> $drsVm.RemoveKey = $_.Key
>> $spec.DrsVmConfigSpec += $drsVM
>> }
InvalidOperation:
Line |
6 | $spec.DrsVmConfigSpec += $drsVM
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The property 'DrsVmConfigSpec' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation:
Line |
6 | $spec.DrsVmConfigSpec += $drsVM
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The property 'DrsVmConfigSpec' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation:
Line |
6 | $spec.DrsVmConfigSpec += $drsVM
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The property 'DrsVmConfigSpec' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation:
Thanks
Looks like you didn't create the $spec content.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
}
The VM Overrides are done on the cluster level, you have to call a Cluster API method.
But since you want to limit the removal to a specific ESXi node, you will have to filter which VMs to add to the $spec.
In the following example, I use a Where-clause.
$clusterName = 'cluster'
$esxName = 'MyESX'
$cluster = Get-Cluster -Name $clusterName
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
Get-VMHost -Name $esxName | Get-VM |
Where-Object { $cluster.ExtensionData.Configuration.DrsVmConfig.Key -contains $_.ExtensionData.MoRef} |
ForEach-Object -Process {
$drsVM = New-Object VMware.Vim.ClusterDrsVmConfigSpec
$drsVM.Operation = [VMware.Vim.ArrayUpdateOperation]::remove
$drsVm.RemoveKey = $_.ExtensionData.MoRef
$spec.DrsVmConfigSpec += $drsVM
}
$cluster.ExtensionData.ReconfigureComputeResource($spec, $true)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can remove the tick from checkbox of DRS automation level with following PowerCLI cmdlets:
get-vm | Where-Object { $_.DrsAutomationLevel -notlike "AsSpecifiedByCluster" } | set-vm -DrsAutomationLevel AsSpecifiedByCluster -Confirm:$false
Hi,
I get an error:
Exception calling "ReconfigureComputeResource" with "2" argument(s): "A specified parameter was not correct: spec.drsVm
ConfigSpec[0].key"
At C:\Users\hentho\Desktop\removeVMfromOverride.ps1:15 char:1
+ $cluster.ExtensionData.ReconfigureComputeResource($spec, $true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
You will have to check what is in $spec.DrsVM.
Are there any VMs in there?
Are all these VMs located on the DSC?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you also try the solution provided in Solved: Re: How to disable or remove VM from VMoverrides ? - VMware Technology Network VMTN
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You mean this? it didn't work, got errors. And it doesn't seem to target a Datastore Cluster, instead the Host Cluster?
get-vm | Where-Object { $_.DrsAutomationLevel -notlike "AsSpecifiedByCluster" } | set-vm -DrsAutomationLevel AsSpecifiedByCluster -Confirm:$false
This thread is about DRS on a cluster, not about SDRS
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference