UmmActually
Contributor
Contributor

Single Cluster VM names and datastores

Is there a way to get the VMs and datastores they are on from a single cluster?  Not hitting all the clusters in vcenter?

Thanks for any help.

0 Kudos
2 Replies
LucD
Leadership
Leadership

You can specify the name of the cluster

Get-Cluster -Name MyCLuster | Get-VM
Get-Cluster -Name MyCLuster | Get-Datastore


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
UmmActually
Contributor
Contributor

I think I got it figured out, but thank you.

 

$cluster = Get-Cluster -Name CusterName
(Get-VM -Location $cluster) | Select Name,
@{N="Datastore";E={[string]::Join(',', (Get-Datastore -Id $_.DatastoreIdList ))}} | where {$_.Datastore -match "datastorename"} | Export-Csv

0 Kudos