We run a daily script checking the configuration and status of ESXi hosts on multiple vCenters (>100) using the following:
Foreach ($vC in $vCList){
$ESXiHosts = Get-View -viewtype hostsystem -property Name,OverallStatus,Summary,AlarmActionsEnabled,Config,TriggeredAlarm,VM,ConfigIssue | Sort-Object Name
}
Does anyone know how to modify the above Get-View command so that it filters out the ESXi hosts in clusters matching the *Build cluster wildcard?
As there are so many vCenters, clusters and ESXi hosts involved, speed is the most important factor I'm looking for in the script.
I tied the following, but keep getting errors:
1.)
Get-Cluster | ? {$_.Name -NotLike "*Build"} | Get-VMHost | Get-View
2.)
$FilteredESXiHostList = Get-Cluster | ? {$_.Name -NotLike "*Build"} | Get-VMHost
Get-VMHost $FilteredESXiHostList | Get-View
With a RegEX expression that uses negative lookbehind, you can filter out all clusters with a name that ends in 'Build'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Can HostSystem properties be pulled from the ClusterComputeResource ViewType?
Thanks,
Fin
Or could the Get-View HostSystem ViewType be filtered using RegEx against the Parent (making assumption that the parent of HostSystem is it's Cluster)?
Yes, there is a Host property, containing the MoRef to the ESXi nodes in the cluster.
ForEach-Object -Process {
Get-View -Id $_.Host |
Select @{N='Cluster';E={$cluster.Name}},Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference