VMware Cloud Community
hack3rcon
Enthusiast
Enthusiast

Create a VM via CLI.

Hello,

How can I create a VM by CLI?

Thanks.

Reply
0 Kudos
2 Replies
Alex_Romeo
Leadership
Leadership

Hi,

New-VM - vSphere PowerCLI Cmdlets Reference

Alessandro Romeo

Blog: https://www.aleadmin.it/
Reply
0 Kudos
continuum
Immortal
Immortal

All you need is to echo a few lines into a vmx-file,

create a vmdk with vmkfstools.

register the VM with vom-cmd.

Here is a very simple example ....

mkdir /vmfs/volumes/datastore/test-vm

cd /vmfs/volumes/datastore/test-vm

echo  '.encoding = "UTF-8"'     > test-vm.vmx

echo  'config.version = "8"'     >> test-vm.vmx

echo  'virtualHW.version = "13"'     >> test-vm.vmx

echo  'memSize = "512"'     >> test-vm.vmx

echo  'scsi0.virtualDev = "lsilogic"'     >> test-vm.vmx

echo  'scsi0.present = "TRUE"'     >> test-vm.vmx

echo  'sata0.present = "TRUE"'     >> test-vm.vmx

echo  'usb.present = "TRUE"'     >> test-vm.vmx

echo  'ehci.present = "TRUE"'     >> test-vm.vmx

echo  'scsi0:0.deviceType = "scsi-hardDisk"'     >> test-vm.vmx

echo  'scsi0:0.fileName = "test-vm.vmdk"'     >> test-vm.vmx

echo  'scsi0:0.present = "TRUE"'     >> test-vm.vmx

echo  'ethernet0.virtualDev = "e1000e"'     >> test-vm.vmx

echo  'ethernet0.networkName = "VM Network"'     >> test-vm.vmx

echo  'ethernet0.addressType = "generated"'     >> test-vm.vmx

echo  'ethernet0.present = "TRUE"'     >> test-vm.vmx

echo  'sata0:0.deviceType = "atapi-cdrom"'     >> test-vm.vmx

echo  'sata0:0.fileName = "/vmfs/devices/cdrom/mpx.vmhba64:C0:T0:L0"'     >> test-vm.vmx

echo  'sata0:0.present = "TRUE"'     >> test-vm.vmx

echo  'displayName = "test-vm"'     >> test-vm.vmx

echo  'guestOS = "other-64"'     >> test-vm.vmx

vmkfstools -c 2048m test-vm.vmdk

vim-cmd solo/registervm /vmfs/volumes/datastore/test-vm/test-vm.vmx


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos