Unable to access vCenter Server or ESXi Host Client UI.
Need to identify which virtual machines (VMs) are located on a specific datastore.
Only SSH/CLI access (e.g., via PuTTY) to the ESXi host is available.
When vCenter Server and the ESXi Host Client are not accessible, you can use the ESXi CLI to identify the virtual machines stored on a datastore.
Note: Ensure that SSH is enabled on the ESXi host before attempting these steps.
Open PuTTY (or another SSH client).
Connect to the ESXi host using the management IP address.
Log in with the root account or another administrator account.
Run the following command to view all mounted datastores:
esxcli storage filesystem listThis command displays the datastore names, UUIDs, and mount points (e.g., /vmfs/volumes/datastore1).
Change directory to the datastore:
cd /vmfs/volumes/<datastore_name> ls -lEach folder generally corresponds to a VM and contains .vmx and .vmdk files.
List all VM configuration files (.vmx) stored on the datastore:
find /vmfs/volumes/<datastore_name> -name "*.vmx"Example output:
/vmfs/volumes/datastore1/Win2022/Win2022.vmx /vmfs/volumes/datastore1/LinuxVM/LinuxVM.vmxTo extract the configured display names from the .vmx files, run:
grep displayName /vmfs/volumes/<datastore_name>/*/*.vmxExample output:
/vmfs/volumes/datastore1/Win2022/Win2022.vmx:displayName = "Windows Server 2022" /vmfs/volumes/datastore1/LinuxVM/LinuxVM.vmx:displayName = "Ubuntu-TestVM"You can list all VMs currently registered on the ESXi host and map them to the datastore:
vim-cmd vmsvc/getallvmsThis command displays VM IDs, VM names, and datastore paths.
If you know the datastore name, you may run the below command:
find /vmfs/volumes/<Datastore_name>/ -name "*.vmx" | sed 's#.*/##' | sed 's/\.vmx$//'
find /vmfs/volumes/<Datastore_name>/ -name "*.vmx" | sed 's#.*/##' | sed 's/\.vmx$//' | wc -l ----> This will get the total number of VMs on the specific datastorefind /vmfs/volumes/<datastore> -name "*.vmx" ---> list all the VM names presented on the datastore