Thursday, March 13, 2014

Deploying multiple VM's using VMware PowerCLI

Today we will detail how to deploy multiple VM's ( I would say the minimum number you want to do this is at 10 VM's, however up to you)

The question is not to just deploy 10+ VM's of the same configurations, then you dont need this, you can do a simple one liner, or you could follow this post.

We are talking about deploying let's say 25 VM's, but from a certain template, and into a specific folder and each VM has a different hostname, memory allocation and CPU, as well as a static IP.

In this case, you need to create an excel file, which you'll save as CSV, with the following columns:


You could add some more columns in there if you wanted, for example for the memory and CPU.

Then you would need to install PowerCLI of course, I have another post talking about that briefly, 

You would then put this CSV file in the directory of your choice, in my case it's at C:\Scripts\
and modify this command below to your likings.  I highlighted the parts you need to change:

Import-Csv "C:\Scripts\NewVMsCR2.csv" -UseCulture | %{
    Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.IPAddress -SubnetMask $_.Subnetmask -DefaultGateway $_.DefaultGateway
    $vm=New-VM -Name $_.VMName -Template $_.Template -Host $_.VMHost -Location "WEB SERVERS" -Datastore $_.Datastore -Confirm:$false -RunAsync -OSCustomizationSpec $_.Customization

You do need to have the template that's referenced in the excel sheet, as well as the customization profile, and in the case of the command above, also the folder "WEB SERVERS"  otherwise it will error out.

However once all is ready, you are now ready to deploy as many VM's as you need.

Here is a picture of it in action (some IP's changed for security reasons)


  1. is there any diff b/w deploying multiple windows vms Vs linux vms ???

  2. I dont think so, I am going to deploy a bunch in a few weeks, I will update then!