VMware Cloud Community
pocketsevens
Contributor
Contributor

PowerCLI Set-CDDrive cmdlet gives strange error

So I wrote a function for my VMware management scripts that disconnects any ISOs that may be mounted to a VM.

The command I used:  Get-CDDrive -VM $vm | Set-CDDrive -NoMedia -Confirm:$false

The error I get: "Device 'ide1:0' already exists."

The strange thing is, it works as intended.  And within the script, I can suppress the error.  But my 'Recent Tasks' in vSphere gets spammed when I run the function against a large series of VMs.

Anyone seen this?

22 Replies
william_faulk
Contributor
Contributor

Actually, I just found that I have others that have CDs on IDE1:0 that don't exhibit this problem.  So I did a network snoop (via Wireshark and its SSL decrypter) to compare, and I found that the SOAP request being made to my vCenter server was identical other than the content of /soap:Envelope/soap:Body/ReconfigVM_Task/_this[@type='VirtualMachine'] (pseudo-XPath notation), which was vm-757 vs. vm-723.  (I determined this by running each SOAP request through xmllint --format and running those results through diff.  That one line was literally the only difference.)


The rest of the SOAP requests were incidental or requesting status on the task.


This would imply that there's something in vCenter and/or ESXi that is causing that error and that PowerCLI is just reporting the error.  Of course, why it doesn't happen when the same task is requested via the Web Client is strange.  Maybe I'll try and capture that data, too, and see what it's doing differently.

0 Kudos
william_faulk
Contributor
Contributor

It turns out that the Web Client proxies everything through Flash AMF Objects and it was being a real pain to decode, so I gave up and looked at what the Windows "fat" client does.  I found that the biggest difference is that PowerCLI sets the CD drive to "VirtualCdromRemotePassthroughBackingInfo" in "Exclusive" mode and the fat client sets the CD drive to "VirtualCdromRemoteAtapiBackingInfo" and does not specify exclusivity.

The other thing that I noticed is that the system that complains has a VM Version of 10, which means that the fat client won't edit its settings at all, whereas the other is on version 9, and snooping on that one was where I saw the different backing type, so the backing type difference may be a red herring.

0 Kudos
klengel
Contributor
Contributor