-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.

1
  • Do you NEED to do this via PowerCLI? it's all there in vCenter Commented Jun 29, 2015 at 12:12

1 Answer 1

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 
2
  • Next time, maybe mark this as a duplicate and reference the other answer.. Commented Jun 30, 2015 at 3: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. Commented Jul 1, 2015 at 11:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.