Skip to content

Instantly share code, notes, and snippets.

@Admin0fThings
Last active August 1, 2020 16:28
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 Admin0fThings/40dd710435020d25e4edf7bb393cec63 to your computer and use it in GitHub Desktop.
Save Admin0fThings/40dd710435020d25e4edf7bb393cec63 to your computer and use it in GitHub Desktop.
Get VMs and Clusters
# Get all clusters
$clusters = Get-Cluster
# Loop through each cluster
$result = foreach ($cluster in $clusters) {
     # Use calculated properties to create custom object
     Get-VM -Location $cluster | Select @{n='Cluster';e={$cluster}},@{n='VM Name';e={$_.Name}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment