DRS Rule for Host affinity check names of datatore that they match to the hosts

DRSRules - list of host affinity rules

Host affinity rules

Cluster

Activated

Name

Solidarity

VM

Host of the rule

Running

Cluster-SA1

TrueCluster2-SA1-VMsHostsFakeSMV - SA1SA1sa1_host3

Cluster-SB2

True

CLUSTER1-SB2-VMsHosts

Fake

SMV - SB2

SB2

sb2_host2

This module of vCheck will show me if one of my virtual machines are not running according to the rules, but I want to look deeper.

DRS Rule for Host affinity check names of datatore that they match to the hosts

Our guests all start with three characters make the difference between SiteA1 and SiteB1, that is sa1host1 sa1host2... sa1host9 and sb2host1, sb2host2, sb2host9, etc.

Our warehouses are the names "sa1_exch01", "sa1_sql_01", sa1_data_01"for all data stores that are found on the Site1.  While the warehouses of data named 'sb2_exch01', 'sb2_sql_01', sb2_data_01' for all data stores that are found on the Site2.

Can help you with a script that will check all virtual machines on the hosts on Site1 and report those who have warehouses of data does begin with 'sa1' and similarly all virtual machines on the hosts on the Site2 but give report of those who have warehouses of data that do not begin with "sb2.

See you soon

KC

Try something like this

$vms = Get-View -ViewType VirtualMachine -Property Name,Datastore,"Runtime.Host"

foreach($vm in $vms){    $esx = Get-View $vm.Runtime.Host -Property Name    $ds = Get-View $vm.Datastore -Property Name    if($ds | where {$_.Name.Substring(0,3) -notmatch $esx.Name.Substring(0,3)}){        $vm | Select Name,            @{N="Site";E={if($esx.Name.Substring(0,3) -eq "sa1"){"SiteA1"}else{"SiteB1"}}},            @{N="Host";E={$esx.Name.Split('.')[0]}},            @{N="DS";E={[string]::Join(',',($ds | %{$_.Name}))}}    }}

It should list all the virtual machines that do not follow the rule.

Tags: VMware

Similar Questions

Maybe you are looking for