Automation

 View Only
  • 1.  Single Cluster VM names and datastores

    Posted Jun 22, 2022 03:18 PM

    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.



  • 2.  RE: Single Cluster VM names and datastores

    Posted Jun 22, 2022 03:37 PM

    You can specify the name of the cluster

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


  • 3.  RE: Single Cluster VM names and datastores

    Posted Jun 22, 2022 08:16 PM

    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