VMware Cloud Community
js40687
Contributor
Contributor

New-VM An item of the same key has already been added

Hi

I'm trying to automate the deployment of Windows and Linux VMs. I'm nearly there. One thing I notice in testing, occasionally when launching the New-VM command, with all the necessary parms I get the error in the title of this post. It doesn't stop the VM being created but it skips on to the next command in the script without waiting for the deployment to finish.

I then have the problem of having to sleep the script until the VM is completely deployed

I'm guessing this is due to re-using VM names. I can delete it in vCenter but something is left hanging around in the system and re-use causes the problem above

Has anyone else seen this? found what it is you additionally have to delete to avoid the error and therefore make the command wait until VM deployment completion before continuing

It is the determining how long to sleep when this happens that is causing me the problem

Any ideas anyone?

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Do you get the error only on the 1st invocation of the New-VM cmldet ? See 4.  Re: First New-VM : An item with the same key has already been added.

Are you using the lasest PowerCLI build 5.5 R1 ?

I have also seen the error pop up when the new VM is cloned from a VM that had a snapshot.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
js40687
Contributor
Contributor

Hi Luc

I’m not using the latest 5.5 version no, still on 5.1, wasn’t aware 5.5 was out, I will have a look to see if that resolves the issue tho

As my script makes a vCenter connection, attempts the deployment then drops the connection, I guess it is always the 1st invocation. Not sure how easy it would be to trip the error and catch it tho as like I said it doesn’t actually stop the new VM being deployed, so I would have to deploy a dummy VM 1st so I could then deploy the real VM without the error

I will try the 5.5 version first tho

Thanks

Jim

Reply
0 Kudos
js40687
Contributor
Contributor

I have now tried PowerCLi 5.5 and the problem seems to be fixed there

Thanks

Reply
0 Kudos