VMware Cloud Community
theyssef
Contributor
Contributor
Jump to solution

An Item with the same key has already been added

Hello All,

I'm seeing a strange issue when trying to add a new-disk to a VM through powershell

I use the following commands:

Add-PSSnapin VMware.VimAutomation.Core

connect-viserver -server $MyVC

$server='MyServer'

$vm=get-vm $server

$NewDisk= New-HardDisk -VM $VM -CapacityGB $DiskSize -StorageFormat $StorageFormat

When I execute it, the disk gets added but the following is thrown into the output:

New-HardDisk : 24/06/2013 11:04:22New-HardDisk    An item with the same key has already been added.

At line:1 char:11

+ $NewDisk= New-HardDisk -VM $VM -CapacityGB $DiskSize -StorageFormat $StorageForm ...

+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : NotSpecified: (:) [New-HardDisk], ViError
+ FullyQualifiedErrorId : Client20_VirtualDeviceServiceImpl_NewVirtualHardDisk_ReconfigError,VMware.VimAutomation.

   ViCore.Cmdlets.Commands.VirtualDevice.NewHardDisk

When I rerun the command in the same powershell session then it gets executed without error.

Has anyone seen this behavior before?

Could this be a bug?

I've been looking for this error but this seems to be something very generic..

Many thanks in advance!

Filip

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Hi Filip,

this looks like the same problem as already reported in First New-VM : An item with the same key has already been added.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
1 Reply
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Hi Filip,

this looks like the same problem as already reported in First New-VM : An item with the same key has already been added.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos