All,
I need to setup one or more PowerCLI scripts that checks site affinity for VMs in a stretched cluster. Would like to have it run daily and email a report. The logic for the script that I need to build is below. If anyone has created a script like this before or has suggestions, it would be much appreciated.
If VM has one or more disks in a datastore that start with "metroA", verify VM is in DRS VM Affinity group called "datacenterA". If not, add to list/array X.
If VM has one or more disks in a datastore that start with "metroB", verify VM is in DRS VM Affinity group called "datacenterB". If not, add to list/array Y.
In addition, check to see if VM is a member of the datacenterA group AND the datacenterB DRS groups. If so, add to list/array Z.
Email report that includes the following....
The following VMs have one or more disks in a datastore that start with "metroA" but are not in the "datacenterA" affinity group. Please check.
List/array X of VMs, or if no VMs found, then it states so below
The following VMs have one or more disks in a datastore that start with "metroB" but are not in the "datacenterB" affinity group. Please check.
List/array Y of VMs, or if no VMs found, then it states so below
The following VMs were found to be members of the datacenterA group AND the datacenterB DRS groups. Please check.
List/array Z of VMs, or if no VMs found, then it states so below