Zeesyed
Contributor
Contributor

Deploy 200 VMs using script.

I have to deploy around 200 vms for a project. I have a customization specification that can be used. Please help me with a script that can feed from the server names in a text file. I will appreciate your suggestion and help.

0 Kudos
6 Replies
Grzesiekk
Expert
Expert

I think your question is too general.

if you want to deploy something 200 times you need to reapeat this step 200 times for example:

foreach($vmname in gc c:\vmlist.txt){

if($vmname){

new-vm -Name $vmname -Template Your_Template -ResourcePool (Get-cluster YOUR_CLUSTER) -Datastore YOUR_DATASTORE -OSCustomizationSpec "your_custom_spec"

}

}

Assuming you have some template from which you want to deploy it.

Question is do you want 200 vms put in the same datastore.

Greg

--- @blog https://grzegorzkulikowski.info
0 Kudos
Sawkat
Contributor
Contributor

You can deploy one vm with all your apps installed and from there use ovftools to deploy other vms from this one through a script. With ovftool you can set options like:

Portgroup

datastore

host

cluster etc etc

for each vm and if you need to add additional customization, then shut down the first vm, go to edit settings->options->Advanced and in the properties... you can set as many options as you want. Then export it as and ovf/ova... and voila... you can use simple scripts to run

ovftool --diskMode=thin -ds=<datastore> -n=<portgroup>  --acceptAllEulas --prop:Password=<password>  --prop:ManagementIpV4=<ip> --prop:ManagementIpV4Subnet=<subnet> --prop:GatewayIpV4=<ipGateway> --deploymentOption=Typical --powerOn <OVApath>  vi://root:<password>@<vCenterIp>/<cluster>/host/<hostIp>

hope this helps

0 Kudos
Zeesyed
Contributor
Contributor

Great question. We have DRS configured on our datastores we have Datastore cluster that will distribute accordingly. I hope this script is good for datastore cluster as well.

0 Kudos
Zeesyed
Contributor
Contributor

Nice suggestion, I will try that as well thank you so much.

0 Kudos
Chrisxxxx
Contributor
Contributor

  This is what I wrote for our company and it's been working great for a couple of years.  Once you have the supporting scripts and files in place it's just filling out a CSV file and letting it run.  You will have to change the path in the "$scriptdir" variable and change/make the subdirectory for the guestids_list.csv file.  I have the Get-DatastoreMostFree.ps1 and Get-mDatastoreList.ps1 as separate functions because they are also used from other scripts.  The guestids_list.csv file has to be updated whenever VMware makes new ones, like vSphere 5.1 has new ones for Windows Server 2012, I believe.

  Limitations are that it only deploys from templates, and it adds one disk.  That matches 99% of the VMs we support, where the template has one standard size disk for the OS and the scripts adds a variably sized disk for the data.

  If you want empty shells then the New-VM cmdlet is all you need.

hth,

-Chris

0 Kudos
Zeesyed
Contributor
Contributor

Thanks! I will have to look deeper into your scripts. I will keep you updated.

0 Kudos