VMware Cloud Community
nmbgdc
Enthusiast
Enthusiast
Jump to solution

How to disable or remove VM from VMoverrides ?

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

 

 

 

 

 

 

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
21 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

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 ?

VM-Overrides.JPG

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

I am looking for either to remove the vm from the list or remove the full list.

yes you understand correct.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

Thanks LucD, It works.

Tags (1)
Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

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

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like you didn't create the $spec content.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nmbgdc
Enthusiast
Enthusiast
Jump to solution

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

}

 

 

 

Tags (1)
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
iivanov1
VMware Employee
VMware Employee
Jump to solution

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

 

Reply
0 Kudos
henketh
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
henketh
Contributor
Contributor
Jump to solution

I don't know how to "check what is in $spec.DrsVM"?

See attached screen shot, that's the VMs I would like to be removed from the VM Overrides list. I want the list to be empty.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
henketh
Contributor
Contributor
Jump to solution

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 

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

This thread is about DRS on a cluster, not about SDRS 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos