I know that there is a lot of info out there about this and I think I have a prety good working script. A lot was borrowed from this thread, http://communities.vmware.com/thread/315193 many thanks to LucD.
My code is as follows:
## Deploy VMs from CSV File
## Much borrowed from http://communities.vmware.com/thread/315193?start=15&tstart=0
## Imports CSV file
Import-Csv "C:\guests.csv" -UseCulture | %{
## Gets Customization info to set NIC to Static and assign static IP address
Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | `
Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" `
-SubnetMask $_.Subnet -DefaultGateway $_.Gateway -Dns $_.DNS
$vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" `
-Datastore $_.Datastore -OSCustomizationSpec $_.Customization `
-Confirm:$false -RunAsync
## .......
}
It will go through and clone the VM, and then it looks like it is running the OSCustomizaitonSpec and then it bombs. It does clean up the bad VM. The Recent Tasks shows "clone virtual machine fails a specified parapeter was not correct. hostname"
The issue is that I am not trying to set a hostname with the OSCustomixationSpec, I am only trying to put in IP address info.
I am runningn PowerCLI 5.0.1 build 581491
My ESXi host is 5.0.0 build 914586
My vCenter Server is Ver 5.0.0 build 623373
I opened a new thread, becuase the age of the old thread. Not sure if that is the best way to do things.