To generate a list of virtual machine names, the associated .vmx/.vmtx files, and their locations:
Note: You require access to run a query against the vCenter Server database from within SQL Management Studio, or a similar tool for non-Microsoft databases.
- Click the New Query button within SQL Management studio.
- In the query editor, run this query:
if it is vPostgres
log-into vcdb using
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgresExecute the below command, this command is safe and will give only output so no need to take a vcdb backup.
VCDB=# select vpx_entity.Name as "VM Name",vpx_vm.file_name as "File Name / PATH" from vpx_vm inner join vpx_entity on vpx_vm.id = vpx_entity.id order by vpx_entity.name;
VM Name | File Name / PATH
---------------------+----------------------------------------------------------------------------------------------------
vm1 | ds:///vmfs/volumes/5ba12e8e-dc89f0a8-f12c-002564fd5bf1/vm1/vm1.vmx
vm2 | ds:///vmfs/volumes/5ba12e8e-dc89f0a8-f12c-002564fd5bf1/vm2/vm2.vmx
use VIM_VCDB;
select VPX_ENTITY.NAME as "VM Name", VPX_VM.FILE_NAME as "File Name / Path"
From VPX_VM inner join VPX_Entity
on vpx_vm.ID = vpx_entity.ID
order by VPX_entity.name
The query returns a list similar to:
Note: This list shows all virtual machines and templates and their associated file. Datastores are denoted by their UUID, not by their friendly name.
| VM Name | File Name / Path |
1 | VM1 | sanfs://vmfs_uuid:4e0922a4-784a49a3-b244-0018fe759255/VM1/VM1.vmx |
2 | VM2 | sanfs://vmfs_uuid:4e092191-14ec1e79-a925-0018fe759266/VM2/VM2.vmtx |