Skip to content

Instantly share code, notes, and snippets.

@jeffgreenca
Created October 12, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffgreenca/496ef6f3605c6fc79374 to your computer and use it in GitHub Desktop.
Save jeffgreenca/496ef6f3605c6fc79374 to your computer and use it in GitHub Desktop.
get-datacenter | foreach {
$dc = $_.Name
$_ | get-cluster | foreach {
$cluster = $_.Name
$count = (get-view -viewtype "VirtualMachine" -Property Name -Filter @{"Runtime.PowerState"="PoweredOn"} -SearchRoot (get-view $_).moref | Measure-Object).Count
write-output "$dc, $cluster, $count"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment