PowerCLI – Identify and disconnect all CD drives from VMs

In this article I will explain how you can easily identify and disconnect connected CD drives from VM’s on VMware vSphere using a simple PowerCLI command.
Connected CD drives can cause issues when you for example want to remediate your VMware vSphere cluster using the Update Manager.

The operation is not allowed in current state

The operation is not allowed in current state

Find and disconnect all CD drives from VM’s

The first step is to connect to the vCenter server, using the Connect-VIServer command,

The second line of code will identify which VM’s have a mounted CD drive.
All VM’s with a mounted CD drive have a value in the IsoPath:

all-vms-with-connected-cd-drive

The third line of code will select all VM’s and change the state of the media to No Media.

Now, run the first command again.
After running the command, you will see that the ISOPath for all VM’s is empty now.

IsoPath is empty!

IsoPath is empty!

Good luck!

Other PowerCLI related blogs can be found here

556 total views, 10 views today

AboutMarc Roeleveld

Cloud Engineer @ Uniserver Internet | vExpert 2019

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code