Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 251495

Re: Help with script to gather cluster info

$
0
0

Hello, jaydo123-

 

By the error, it seems that there might be a cluster that has no hosts in it.  Do you know of such a cluster in your environment?  I tested in an environment with an empty cluster, and with the original code, received the same error that you reported.

 

You could quickly check for clusters and their number of hosts with:

 

Get-Cluster | Select-Object Name,@{n="NumHosts"; e={($_.ExtensionData.Host | Measure-Object).Count}}

 

If it is the case that a host-less cluster is causing issue here (and, to make the script a bit more flexible), you could change that first portion of the first Foreach loop to something like:

 

Foreach ($clusterinGet-Cluster) {
   
$esx=$cluster | Get-VMHost
   
## only get datastores if Get-VMHost returned any hosts
    $ds=if ($esx) {Get-Datastore -VMHost $esx | where {$_.Type -eq"VMFS"-and (Get-View$_).Summary.MultipleHostAccess}} else {$null}
    ...

 

That way, it will only call Get-Datastore each time through if there were VMHosts in the cluster for which the script is currently gathering data.

 

What kind of a difference does that make for you?


Viewing all articles
Browse latest Browse all 251495

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>