I have a build script to build multiple servers at a time. Only on the first VM when running the script I get this error.
New-VM : 3/5/2012 4:43:16 PM New-VM An item with the same key has already been added.
At C:\Users\XXXXXXXX\Documents\PowerCli\Deploy\DeployFromTemplate.ps1:67 char:10
+ New-VM <<<< -Template $template -VMHost $vmhost -Name $vmname -Datastore $datastore `
+ CategoryInfo : NotSpecified: (:) [New-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
I do not get it on any of the other ones after that. I am wondering if this is a true error or more informational? All the VMs get build correctly using the script.
Can you please post the script in DeployFromTemplate.ps1.
Thanks!
Script attached to original post.
Could it be that there are VMs in your CSV that already exist ?
Does this return anything ?
Import-Csv -Path '\\ltcvc02\d$\Scripts\VM_PowerCLI_Deployment\NewVMs.csv' | %{ Get-VM -Name $_.vmname -ErrorAction SilentlyContinue
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No I do not get any errors when I step throught the script in PowerGUI. Only when I build the first VM.
Looks like it may be a powercli issue. I've seen a few threads with this same issue. See the last post here for a fix/workaround:
http://communities.vmware.com/thread/298488?start=0&tstart=0
From all the posts looks like a coding issue. Im not going to worry about it since it does not prevent the VMs from being built.
