VM creation with ACLI | Nutanix Community
Skip to main content

So I use the following script to create a VM. I actually have a small batch file that opens putty, logs into a CVM, prompts me for the $name and then runs the script below. The image is one I made, then sysprepped and uploaded as a disk image.

Everything works great except that when I then open the console it goes through the Windows setup. I have an Unnattend file but I am unsure how to use it with my script. If I go through the GUI to create a VM I just point it to the unattened file in our file share.

Is there a way to attach the sysprep file? I thought it might be a parameter vm.disk_create but I am not clever enough to figure that part out and thought maybe someone else smarter could help. First world problems I know but it could help save me 30 extra seconds of not having to type the admin password in and set the keyboard settings etc.

#creates a vm
acli vm.create $name memory=$mem num_cores_per_vcpu=$core num_vcpus=$vcpu uefi_boot=TRUE &&

#Create C:
acli vm.disk_create $name clone_from_image=$image &&
#
#creates a D drive
acli vm.disk_create $name bus=scsi create_size=$hd index=1 container=$container ;

#create CD ROM drive
acli vm.disk_create $name bus=sata cdrom=true empty=true ;

#Add a NIC
for i in $(eval echo "{1..$END}"); do acli vm.nic_create $name connected=true network=$vlan request_ip=true; done ;


#Add VM to protection domain
ncli protection-domain protect name=$domain vm-names=$name &&


#powers on vm
acli vm.on $name

Thanks in advance

So I figured out a way to do this.

I used the following command:

acli vm.disk_update $name disk_addr="sata.0" clone_from_image="AutoUnattend.iso"

I created an ISO with my Answer file in the root and uploaded the image to Prism. Make sure it is called “unattend”. I could have sworn Windows required it to be named AutoUnattend.xml but that didn’t work until I changed the name.

So this will work like the GUI where you can upload an Answer file when creating a VM but without using a GUI because yuck.

I could also put the answer file in my image and have it run that way but 1. If I update my answer file I have to update my image. 2. I can use different answer files with the image.

My next step may be to get this loop for more than 1 VM and/or create them from a CSV (not sure if that will be possible).