I'm looking for a way to automate a large number of VM deployments using an array of IP addresses. First, however, I need to figure out how to pass the static IP parameter to the -OSCustomizationSpec property. The customizations we have created prompt for an IP address when using the wizard in the vSphere client. When running the command in PowerCLI, I'm not even prompted, nor could I find any documentation on how to pass an IP in the New-VM command. Anyone know this one?
PowerCLI C:\Scripts> New-VM -Name $servername -ResourcePool $clustername -Template $templatename -OSCustomizationSpec $customization
New-VM : 8/21/2013 1:20:54 PM New-VM The operation for the entity VirtualMachine-vm-98404 failed with the following message:
"A specified parameter was not correct.
nicsettings:adapter:ip"
At line:1 char:7
+ New-VM <<<< -Name $servername -ResourcePool $clustername -Template $templatename -OSCustomizationSpec $customization
+ CategoryInfo : NotSpecified: (:) [New-VM], InvalidArgument
+ FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets
.Commands.NewVM
Second part, but much less important: If you don't specify a datastore in the command, what logic does vSphere use to determine which datastore to use? This is mostly a curiosity that a quick google search couldn't help me find.