VMware Cloud Community
benham
VMware Employee
VMware Employee

Set-CDDrive IDE Mode

Hi,

I know we can use "Set-CDDrive -nomedia" to blank out the ISOPath or hostDevice, basically, setting the CDDrive to Client Device.

However, the mode always default to "Passthrough IDE (recommended)" and checked "Connect exclusively to this virtual machine".

How do I change the mode to "Emulate IDE"? This is the default if you change using VI Client.

Cheers!

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

To set the CDDrive to "emulate IDE" you have to use the ReconfigVM method.

The following filter implements this

filter set-cddrive-emulateIDE{
  $vm = Get-View $_.ID
  $i = 0
  foreach($dev in $vm.Config.Hardware.Device){
    if (($dev.GetType()).Name -eq "VirtualCdrom"){
      $spec = new-object VMware.Vim.VirtualMachineConfigSpec
      $spec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
      $spec.DeviceChange[$i].device = $dev
      $spec.DeviceChange[$i].device.Backing = New-Object VMware.Vim.VirtualCdromRemoteAtapiBackingInfo
      $spec.DeviceChange[$i].device.Backing.deviceName = ""
	  $spec.DeviceChange[$i].operation = "edit"
      $i++
    }
  }
  if ($i -gt 0) {$vm.ReconfigVM($spec)}
}

It can be used like this

Get-VM -Name <VM-name> | set-cddrive-emulateIDE

or

Get-VM | set-cddrive-emulateIDE


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
regis
Contributor
Contributor

Hello LucD

About ReconfigVM method, how to check radio button "Passtrough IDE (recommended)" and uncheck "Connect Exclusively to this Virtual Machine" ?

this is default parameters from new VM

many thanks

Régis

Reply
0 Kudos
regis
Contributor
Contributor

done, i find it ...
$spec.DeviceChange[$i].device.Backing = New-Object VMware.Vim.VirtualCdromRemotePassthroughBackingInfo
$spec.DeviceChange[$i].device.Backing.Exclusive = $true
thanks

Reply
0 Kudos
mossko
Contributor
Contributor

Thanks for that LucD, worked a treat!

I used Onyx to grab some of the $spec code but it didn't work on some of the older VMs upgraded from vmhw-v4

Reply
0 Kudos