VMware Cloud Community
AndrewGrowcock
Contributor
Contributor

Remove virtual machines from DRS group

I'm trying to automate my DRS VM Groups.  I am running a stretched cluster that operates between 2 physically seperated datacenters (dc1 and dc2).  My datastores and vm groups are named to reflect which datacenter that resource lives in. What I've done is I first have a script that goes out and finds all vm's that reside on dc1 datastores and outputs to vms. I then copied the script from vRO called "Remove virtual machines from DRS group" to then compare the dc1 vms to what is in the current dc2 DRS vm group. I want to remove any vms that may have migrated from dc2 to dc1.  It looks like this script fist copies what is currently in the vm group to preserve it and in the end never removes any vms. Do I need to add a compare somewhere in here?

Reply
0 Kudos
2 Replies
qc4vmware
Virtuoso
Virtuoso

If you are moving vm's from one datacenter to the other it should automatically be removed from drs group one.  drs groups are associated with a cluster.  You will have to add it to the drs group for the new cluster.

Reply
0 Kudos
AndrewGrowcock
Contributor
Contributor

Physically we have 2 Datacenters, but in VMware we have 1 Datacenter and 1 Stretched Cluster that spans both physical Datacenters.
Reply
0 Kudos