VMware Cloud Community
TerryOdom
Contributor
Contributor

How do you export a list of VMs in a Cluster?

I'm a newbie to PowerCLI so please bare with me.  I am trying to export a list of VMs within a cluster to excel with the following information:  Guest OS, DNS Name, Host, and datastore VM is on.

Simple request for the vets out there but I'm still trying to work it out.  Let me know if I need to provide additional information.  Thanks!

0 Kudos
4 Replies
Mouhamad
Expert
Expert

Hi,

I'm not sure if you're looking only for powercli. However, this can be done on GUI.

Click on the cluster, choose virtual machines, right click  on a blank space and choose Export list. (Check attached)

Regards,

VCP-DCV, VCP-DT, VCAP-DCD, VSP, VTSP
LucD
Leadership
Leadership

Try something like this

Get-Cluster -Name MyCluster | Get-VM |
Select Name,@{N="OS";E={$_.Guest.OSFullName}},
    @{N="DNS";E={[string]::Join(',',($_.Guest.ExtensionData.Net[0].DnsConfig.IpAddress))}},
    @{N="Host";E={$_.Host.Name}},
    @{N="Datastore";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name}))}} |
Export-Csv .\report.csv -NoTypeInformation -UseCulture    
     

The script assumes your VM only has 1 NIC.


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

0 Kudos
TerryOdom
Contributor
Contributor

This was definitely a good option.  I just wasn't sure how choose a datastore.  It didn't look like a datastore column was available.  Very helpful though.  Thanks!

0 Kudos
TerryOdom
Contributor
Contributor

I'll have to play around with this and see if it helps.  It'll take me a while since I'm a newbie.  Thanks!

0 Kudos