Deploy Linux VM from template with Guest Customization

Based on various forum postings and numerous articles i still haven't completely understood how to achieve the following scenario in a powercli script. any guidance is highly appreciated.


Linux Template - Name: LX-RHEL6x-template

GuestCustomSpec: - Name: static-lx-nw


Linux Template is pre-configured with required HDDs and network adapters. Customization Specs is preconfigured with all settings and expects IP address for adapter1 and adapter 2 is set to DHCP. I have to deploy about 50 VMs in multiple different environments and am trying to script this to ease my deployments.

deploy target:

Cluster Name: QA

Resource Pool: Normal

Datastore: StrgCluster01


CSV file containing following details.


So far i have following script info from one of the discussion thread here however i am not sure how i can achieve the above using this script or how to modify it as i already have netmask etc. predefined in the customspecs.

Import-Csv "C:\Uscripts\NewVMs.csv" -UseCulture | %{

    Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.ip -SubnetMask $_.subnet -DefaultGateway $

    $vm=New-VM -Name $_.Name -Template $_.Template -Host $_.Host -Datastore $_.Datastore -Confirm:$false -RunAsync -OSCustomizationSpec $_.Customization


0 Kudos
1 Reply

At first sight that should work.

The settings in the template will indeed be overrules by the ones in the OSCustomizationSpec.

Do you have any errors or issues with the script ?

Blog:  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos