VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Set-CDDrive -Force switch

When trying to dismount a CD ISO mounted in an OS, it's very common that the OS has some hold on that ISO that will cause attempts to disconnect the CDDrive to create a VM Question asking for confirmation to force the dismount. One can attempt complicated methods to answer the question, but I think it would make more sense (and more efficient) if we can effectively bypass such questions (or auto-answer them) with use of a -Force switch.

So if I call:

    $vmObj | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false

it will attempt to gracefully eject the CDDrive and if the OS has a lock on it, will spawn the VM question as now.

However, if I call:

    $vmObj | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false -Force

It will bypass the question (or auto-answer it) and dismount the ISO even if the OS has a lock on it.

  • Ryan R
  • Feb 25 2019
  • Attach files