PowerCLI Commands for setting CD Drives to Disconnected and not be set to Host Device or ISO

PowerCLI Commands for setting CD Drives to Disconnected and not be set to Host Device or ISO

#These are just some examples that help me manage the CD Drives connected to the VMs. Simple stuff but I thought I would share incase it helps someone.

#PLEASE CHECK COMMANDS BEFORE RUNNING THEM. These commands do make changes, so just be aware and run at your own risk.

#Also note that when running these commands VMWare may pop up a question(Mostly just linux VMs) which you will need to answer immediately.

#Make sure you're connected to VCenter first

Connect-VIServer servername

#This sets an individual VM's CD Drive to "Client Device" which means it will not be connected to anything unless you connect it.

#Replace vmname with the VMs name.

Get-CDDrive vmname | Set-CDDrive -NoMedia

#Sets all VMs with CD Drives connected to a host device to the "Client Device" which means it will not be connected anything unless you connect it.

Get-VM | Get-CDDrive | ?{$_.HostDevice -match "^/dev/"} | Set-CDDrive -NoMedia

#Sets all VMs with CD Drives connected to a an iso to the "Client Device" which means it will not be connected anything unless you connect it.

Get-VM | Get-CDDrive | ?{$_.isopath -match "\.iso$"} | Set-CDDrive -NoMedia

Version history
Revision #:
1 of 1
Last update:
‎08-19-2010 02:20 PM
Updated by: