VMware Cloud Community
andrevechiatto
Enthusiast
Enthusiast

Function to remove vms from DRS GROUP

I have one function to add vms in DRS group. Is possible remove 1,2,3 etc vms from DRS group with powercli?

7 Replies
LucD
Leadership
Leadership

You might want to look at the Set-DrsVmGroup cmdlet in out DRSRule module.

See DRSRule – a DRS rules and groups module


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

vechiattoa
Contributor
Contributor

Tks your reply.

But dont find option to remove one or two vms. Only find option -Append vm

Reply
0 Kudos
vThinkBeyondVM
VMware Employee
VMware Employee

Yes, It should be possible. Sometime back I had written a blog on editing VM-VM affinity rule (Java SDK). : http://vthinkbeyondvm.com/how-to-edit-drs-vm-vm-affinity-rules-using-vsphere-api-bit-tricky-solution...

I will give a try to achieve your requirement in PowerCLI.


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

Reply
0 Kudos
LucD
Leadership
Leadership

The cmdlet does accept one or more VM.

With the Append switch ($true or $false) you define if these VMs are appended to or replacing the VMs already in the group

vmgroup.png


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

Reply
0 Kudos
AnonAdmin
Enthusiast
Enthusiast

Hi LucD- I've been digging around and am looking for the same solution as the OP. I have an existing DRS rule (VM's to Host's) in my cluster with about 150 VM's in the VM DRS group - I'd like to remove about 60 VM's from this group. It doesn't appears that this cmdelt will perform that task. Am I missing something? Thanks in advance!

Reply
0 Kudos
LucD
Leadership
Leadership

You should be able to retrieve the current VM group with the Get-DrsVmGroup cmdlet.

Then you remove the 60 you doin't want in there, and use a Set-DrsVmGroup to set the updated VM group


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

R2BZ
Contributor
Contributor

For other people who may have the same question.
Yes, it is possible using the module suggested by @LucD https://github.com/PowerCLIGoodies/DRSRule/blob/master/README.md
with the Set-DrsVMGroup command and the -RemoveVM parameter

get-help Set-DrsVMGroup -Examples

Get-DrsVMGroup -Name 'VM Group 1' -Cluster Cluster1 | Set-DrsVMGroup -RemoveVM vm[1-2]
Remove the given virtual machines from DRS VM group 'VM Group 1' on cluster 'Cluster1'
Name Cluster UserCreated VM
---- ------- ----------- --
VM Group 1 Cluster1 False {VM3,VM4}

 

Reply
0 Kudos