Register All VMs on a ESXi Datastore via CLI

ESXi

 

  • All the VMs on the local datastores were still inaccessible since the VMX file was looking for the same datastore and UUID per the .VMX file.
  • SSH into the ESXi host and run this command to Register all .vmx files on each datastore in scope. Replace “Datastore_Name” with the real name. In my lab test setup “nfs2”
  • find /vmfs/volumes/Datastore_Name/ -maxdepth 2 -name ‘*.vmx’ -exec vim-cmd solo/registervm “{}” \;
  • find /vmfs/volumes/nfs2/ -maxdepth 2 -name ‘*.vmx’ -exec vim-cmd solo/registervm “{}” \;
Setup

 

Issue
  • All the VMs on the local datastores were still inaccessible since the VMX file was looking for the same datastore and UUID per the .VMX file.
Fix
  • SSH into the ESXi host and run this command to Register all .vmx files on each datastore in scope. Replace “Datastore_Name” with the real name. In my lab test setup “nfs2”
  • find /vmfs/volumes/Datastore_Name/ -maxdepth 2 -name ‘*.vmx’ -exec vim-cmd solo/registervm “{}” \;
  • find /vmfs/volumes/nfs2/ -maxdepth 2 -name ‘*.vmx’ -exec vim-cmd solo/registervm “{}” \;