[vbox-dev] deleteConfig call problem in Powershell

Alexey Orlov orlov at mail.org
Mon Jun 30 05:35:44 UTC 2014

I've encountered a problem with deleteConfig in Powershell.
I am trying to remove all VM files with a code like this:

$vmMedia = $existingVM.unregister([vboxTypes.CleanupMode]::CleanupMode_DetachAllReturnHardDisksOnly.Value__)
$vbProgress = $existingVM.deleteConfig($vmMedia)

Unregister call works as expected and returns an array of valid IMedium objects. I can iterate through array items and access IMedium properties like $vmMedia[0].Location and so on. But deleteConfig fails with the following message:
Assert failed on "DeleteConfig" with "1" argument(s): "Несовпадение типов. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"

The problem resembles the one described here:

Basically, it seems that media parameter needs to be casted explicitly to an array of IMedium. But I cannot figure out how to do it. (IMedium[]$vmMedia) fails, which is expected - for this (possibly) to work we need fully qualified type name.
I've read everything I could find about COM interfaces in Powershell but didn't find a solution. Maybe anyone can suggest something to try.

At the moment I can work around this problem by calling VBoxManage utility with unregistervm and --delete. But it would be really nice to do everything through API.
My VirtualBox version is 4.3.12 r93733
Tried on different hosts with Windows 7/8 x64 Professional

I'm pretty sure it is a Powershell issue. I created a small VBS script which does exactly the same - it works as expected.

Best regards,
Alexey Orlov

More information about the vbox-dev mailing list