[SOLVED] ESXi Import Wizard - Is there a CLI equivalent

May 16, 2025
11
0
1
Hello,

Thread title essentially says it all.

Is there a CLI equivalent to the WebUI 'ESXi Import Wizard'?

From the description, the 'qm import' command sounds like it might do the trick, but I'm not sure what syntax is expected?

https://pve.proxmox.com/pve-docs/qm.1.html
qm import <vmid> <source> --storage <string> [OPTIONS]
Import a foreign virtual guest from a supported import source, such as an ESXi storage.

The WebUI tool works wonderfully, but I really don't want to have to click 'Import' hundreds of times to migrate my inventory of VMs ;)

Any pointers appreciated.

Thanks,
 
Hi!

Yes, there is and the one you found is also the correct one!

Suppose I want to import the virtual machine with the name TestVM from the ESXi storage esxistore to Proxmox VE on the local storage with vmid 404, then the command would need to be:

Code:
qm import 404 esxistore:ha-datacenter/TestDatastore/TestVM/TestVM.vmx --storage local
 
Hi!

Yes, there is and the one you found is also the correct one!

Suppose I want to import the virtual machine with the name TestVM from the ESXi storage esxistore to Proxmox VE on the local storage with vmid 404, then the command would need to be:

Code:
qm import 404 esxistore:ha-datacenter/TestDatastore/TestVM/TestVM.vmx --storage local
Hi Daniel,

Thank you for the information.

I tried what you recommend above but it wasn't working, I was fat fingering the path to the 'vmx' file.

Thanks again!
 
where does the 404 come from? As this is importing a new VM, it doesn't have a proxmox ID yet, Do we just figure out the highest ID and + 1 ?
 
Thanks .. I did that and it told me 105 ... but I have VMs 701 and 702. So I was hoping for 703.
I'm writing an automation script to migrate VMs from vmware to Proxmox in powershell .. so I get the next ID this way.

Code:
# Get the next VMID
    $endpoint="cluster/resources"
    $URL="https://$phost/api2/json/$endpoint"
    $response = Invoke-RestMethod -Uri $URL -Headers $pHeaders
    $clusterdata = $response.data
    $pxVMs = $clusterdata | where {$_.type -eq "qemu"}
    
    $maxVmid = ($pxVMs.vmid | Measure-Object -Maximum).Maximum
    $nextVmid = $maxVmid + 1

I then use powershell to SSH to a node and run

Code:
"qm import $nextVmid $vmxFile --storage $pxmxStorage"
 
Thanks .. I did that and it told me 105 ... but I have VMs 701 and 702. So I was hoping for 703.
I'm writing an automation script to migrate VMs from vmware to Proxmox in powershell .. so I get the next ID this way.

Code:
# Get the next VMID
    $endpoint="cluster/resources"
    $URL="https://$phost/api2/json/$endpoint"
    $response = Invoke-RestMethod -Uri $URL -Headers $pHeaders
    $clusterdata = $response.data
    $pxVMs = $clusterdata | where {$_.type -eq "qemu"}
   
    $maxVmid = ($pxVMs.vmid | Measure-Object -Maximum).Maximum
    $nextVmid = $maxVmid + 1

I then use powershell to SSH to a node and run

Code:
"qm import $nextVmid $vmxFile --storage $pxmxStorage"
I mistyped in my first response. pvesh get /cluster/nextid returns the first 'free' vmid available. pvesh is calling the rest API, as an example you could call pvesh get /cluster/resources --output json-pretty it will pretty-print the JSON data contained in your $response.data .
 
where does the 404 come from? As this is importing a new VM, it doesn't have a proxmox ID yet, Do we just figure out the highest ID and + 1 ?
FYI this can of course be any vmid, which isn't taken yet by another guest, so calling /cluster/nextid is what the web interface would also do to get the next free vmid when the Create Wizard is opened.