-1

I am trying create a on-liner script which gives an outputs of Hosts and vm's counts in a vcenter cluster like as below.

Cluster:                                                      VMHost                         VM's
Cluster01                                                     04                                  15
cluster02                                                      02                                  35

Just using a sample onliner

Get-VMHost | Select @{N=“Cl“;E={Get-Cluster -VMHost $_}} Name, @{N=“NumVM“;E={($_ | Get-VM).Count}} | Sort Cluster, Name

any Ideas?? Thanks in advance

Regards, Subash.

Jenny D
  • 27,780
  • 21
  • 75
  • 114
suboss87
  • 109
  • 1
  • 2

1 Answers1

0

A bit long for a one-liner, but here you go (again?)

get-cluster | select @{n="cluster";e={$_.name}}, @{n="hosts";e={($_ | get-vmhost).count}}, @{n="vms";e={($_ | get-vm).count}} | sort cluster | ft -auto
noam
  • 111
  • 4
  • Next time, maybe mark this as a duplicate and reference the other answer.. – GregL Jun 30 '15 at 03:44
  • @GregL Seems like the duplicate must be on ServerFault, rather than SO. Offhand the question seems like a better fit for SO. Certainly it's presented more clearly there, though of course that's easily fixed here. – noam Jul 01 '15 at 11:13