VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

Host count Report

Hi

I get the cluster name to export to a csv file but not the count.

It probably is something silly that i am overlooking.

Code:

$Clusters = Get-Cluster

foreach ($Cluster in $Clusters){

    $VMHosts = Get-Cluster $Cluster | Get-VMHost
   
    $TotalBlades = [math]::round(($VMHosts.count.ToString)) |

Select-Object @{N="Cluster";E={$Cluster.Name}},@{N="BladeCount";E={$TotalBlades}} |
Export-csv Blade-Count.csv -NoTypeInformation
   
}

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
AGFlora
Enthusiast
Enthusiast
Jump to solution

Found this one liner that does the trick:

Get-Cluster | Select Name, @{N="BladeCount";E={@($_ | Get-VMHost).Count}} | Export-Csv Blade-Count.csv -NoTypeInformation

View solution in original post

Reply
0 Kudos
2 Replies
AGFlora
Enthusiast
Enthusiast
Jump to solution

Found this one liner that does the trick:

Get-Cluster | Select Name, @{N="BladeCount";E={@($_ | Get-VMHost).Count}} | Export-Csv Blade-Count.csv -NoTypeInformation

Reply
0 Kudos
lakey81
Enthusiast
Enthusiast
Jump to solution

Yea was going to say just change "$TotalBlades = [math]::round(($VMHosts.count.ToString))" to "$TotalBlades = $VMHosts.count".

Reply
0 Kudos