1

I've been attempting to write a script that will create multiple vm's from a given template. But I haven't found much documentation on scripting within the vSphere web client, has anyone done this before?

Dr.Sys
  • 11
  • 1
  • 1
    Take a look at the vsphere automation sdk https://code.vmware.com/web/sdk/6.7/vsphere-automation-python EDIT: there is one for .net https://code.vmware.com/web/sdk/6.7/vsphere-automation-dotnet so it is closer to powershell for you. – Narzard Jul 31 '19 at 18:18
  • also see here: https://www.businessnewsdaily.com/11038-use-powercli-vsphere-deployment.html – Narzard Jul 31 '19 at 18:23

1 Answers1

2

This can be done using powercli for vsphere.

Download PowerCli ( https://www.powershellgallery.com/packages/VMware.PowerCLI/6.5.1.5377412 )

Here is an example of creating a VM:

Connect to my vCenter server named "vcenter" in PowerShell.

C:> Connect-VIServer –Server 'vcenter'

Run New-VM while specifying the VM name, VMHost, datastore, number of CPU's, hard disk size and the network name.

C:> New-VM -Name 'TestVM' –VMHost 'VMHost-1' -Datastore 'TestDatastore' -DiskGB 40 -MemoryGB 8 -NumCpu 2 -NetworkName 'Virtual Machine Network'

Here is an example of **cloning a new template called "Win7Template" from the VM "Win7VM".

C:> New-Template -VM 'Win2012VM' -Name "Server2012R2Template" -Datastore 'TestDatastore' -Location 'TestLocation'
Narzard
  • 3,557
  • 14
  • 27