Export virtual machine list

Solution 1:

In the Windows VMware vSphere Client program --

  1. Select your Datacenter, cluster or host.

  2. Select the Virtual Machines tab.

  3. Right click an empty area of the window and select "Export List".

  4. Type a file name and click the "Save" button.

  5. Done.

Note that the default file type when exporting the list is htm/html but you can change it to xls or csv (among others).

Solution 2:

PowerCLI:

Add-PSSnapin Vim.VMwareAutomation.Core
Connect-VIServer $vCenterServer

Get-VM | Select -Property Name | Set-Content listOfVMs.txt

Somthing similar to that should get you started.


Solution 3:

Edit: it's 2016 now and I still have to deal with these. I now think that cronjobs on the hosts are not reliable at all. The tool I now use to get lists and run basic tasks is govc, vmware's official open source project written in go (cross platform, single binary): https://github.com/vmware/govmomi/blob/master/govc/README.md


I have a cronjob doing this for me on a regular basis (ESXi comes with ESXi shell which might be more familiar for Linux users).

The command is

vim-cmd vmsvc/getallvms | grep -v Vmid | awk "{print \$2}" 

grep here just removes the header.

Both shell and ssh server should be enabled in order for this to work.

I also run this command before running ghettoVCB so that I always backup all of the machines, no matter if any of them had been migrated or created recently.


Solution 4:

In the bottom right of the main virtual machine screen there is an icon to export as a csv. you can select all the items or just one. it allows you to select the different columns for the export also.