I've just read the script and it seems to don't use any OSCustomization template, it make the deal but it's kind of wordy (write each time cpu, ram etc... whereas i already package it on a vcenter customization template)
I think there's something to do with OSCustomizationNicMapping function but i can't manage it ...
Virtual machine templates:
To create a template, create a new virtual machine, install the OS and configure any settings you would like to standardize with future virtual machines. Then you either clone or convert that virtual machine for a template.
Here is an example of cloning a new template called "Win7Template" from the VM "Win7VM".
OS customization specifications are used to automate certain settings and tasks such as setting a computer's hostname and joining a computer to a domain. To create an OS specification we use the cmdlet New-OSCustomizationSpec in PowerCLI.
Deploy a virtual machine from a template and customize settings:
Now that I have a VM template and OS customization specs, I can build a new virtual machine that will have the OS installed, be joined to a domain, set the product key and have the time zone set.
Thanks for answering,
If i follow your example, the GUI specify to "prompt the user for ip address", i have the same behaviour in mine, but when you try to deploy a new vm with the same specification by using PowerCLI, it didn't prompt the ip address and i think we have to specify each parameters manually isn't it ?
So if i use "Set-OSCustomizationNicMapping" to my deploy command line, i'm afraid it will duplicate some settings I've already set using the GUI (dns server, ip to be prompted , netmask etc...)
If you want to be sure, remove them from the customization and insert them into the PowerCli.
Or you can get the addresses by taking them from a CSV file, or set the ipmode = 'PromptUser' parameter.
Set-OSCustomizationNicMapping –IpMode UseStaticIP –IpAddress “192.168.0.101” –SubnetMask “255.255.252.0” –DefaultGateway “192.168.0.1” –Dns “192.168.0.10”
New-OSCustomizationNicMapping –OSCustomizationSpec “BasicWindowsSpec” –IpMode UseDhcp –Dns “192.168.0.10”, “192.168.0.20” –Wins “192.168.0.030”, “192.168.0.40”
Set-OSCustomizationNicMapping –IpMode promptUser –IpAddress “192.168.0.101” –SubnetMask “255.255.252.0” –DefaultGateway “192.168.0.1” –Dns “192.168.0.10”
parameters.JPG 125.2 K
I've tried the one with "UseStaticIP" parameter because it could help me in the future for using .csv doc.
But i still got an error with my cli (i didn't paste the $VMHost, $Template and $Spec but they're ok)
I tried with simple quote and double quote, nothing changes, i've also tried with only one DNS... but still the same error.
The network parameters must be entered without quotes and double quote.
The double DNS must be separated by a comma.
Try like this:
New-VM -Name 'WEB001' -VMHost $VMHost -Datastore 'DST_XXX' -Template $Template -OSCustomizationSpec $Spec | Set-OSCustomizationNicMapping -IPmode UseStaticIP -IpAddress 192.168.0.1 -SubnetMask 255.255.255.0 -DefaultGateway 192.168.0.1 -Dns X.X.X.X.X,X.X.X.X.X
-------------- Example 3 --------------
C:\PS>Get-OSCustomizationSpec mySpec | Get-OSCustomizationNicMapping | Set-OSCus
tomizationNicMapping -IpMode UseStaticIp -IpAddress 10.10.0.1 -SubnetMask 255.25
5.255.0 -DefaultGateway 10.10.0.1 -AlternateGateway 10.10.0.1 -Dns 10.10.150.1 -
Still the same error as i had about nicsettings adapter...
weird isn't it ? i only have 1 nic adapter on my template. Maybe i have to specify it ? I give a try with the "Position 1" parameter, i think it will works !