List of VMX Files

Don’t ask me why but I wanted a list of .VMX files for all of the virtual machines registered in vCenter. With a little experimentation it was easy to come up with a oneliner.

Get-VM | Get-View | % { $_.Config.Files.VmPathName }

However, that’s not the quickest way. The output takes ages to display because each VM is passed along the pipeline one at a time resulting in multiple Get-View queries. The following is faster:

Get-View -ViewType VirtualMachine | % { $_.Config.Files.VmPathName }

Although it is a bigger query, the single Get-View call makes the whole thing so much faster. I learned that the other week at a fantastic VMware event. Cheers Alan.

Now, one question I have. Most of the VMX files returned by this take the following form:

[datastore_name] VM-Name/VM-Name.vmx

However, there were a few that came out as:

[] /vmfs/volumes/datastore-id-string/VM-Name/VM-Name.vmx

Does anyone know why that’s happening? They’re all from the same datastore, perhaps there’s an issue with that…

Michael is a Senior Consultant for Xtravirt. If it's got buttons or flashy lights on it then it'll probably be on his radar. When not "mending computers" (it's sometimes easier than explaining "cloud" to relatives), Michael provides essential education, entertainment and trampoline services to his two children.

Leave a Reply

Your email address will not be published. Required fields are marked *