In ESXi Shell, you may need to know which VM corresponds to which VMID.
To identify which VM Name corresponds to which VMID on your ESXi host, you can use the vim-cmd vmsvc/getallvms
Copy
Search Site
Search Google
command. This command outputs a table of all registered virtual machines.
1. View All VM IDs and Names Run this command to get a clean list of just the IDs and Names: vim-cmd vmsvc/getallvms | awk '{print $1, $2}'
Copy
Search Site
Search Google
2. Formatted Inventory Script If you want a more readable list that clearly separates the ID from the VM name (useful if your VM names have spaces), use this script:
3. Finding the "Skipped" VM If your previous script skipped a VM, it might be due to one of these common reasons:
Invalid/Orphaned VM: If the VM shows as (Invalid) or (Orphaned) in the list, vim-cmd may fail to execute sub-commands (like device management) on it.
Spaces in Names: If you used a script that didn't handle spaces correctly, it might have misinterpreted the VMID.
Permissions: The VM might be locked by another process (like a backup).
How to check a specific ID: If you suspect a specific ID (e.g., 15) was the one skipped, you can check its status directly: vim-cmd vmsvc/getsummary 15 | grep -E "name|powerState"