ejector seat

Eject ISOs from Virtual Machines in a Cluster

Q: How can I eject the ISO files from all DVD drives attached to virtual machines in a cluster?

A: The following PowerShell code will eject the ISO files from all virtual machines in a cluster.

$VMsinCluster = Get-ClusterResource | Where-Object {$_.ResourceType -eq "Virtual Machine"} | Get-VM

foreach ($VM in $VMsinCluster)
    $VMDrive = Get-VMDvdDrive -VM $VM
    if ($VMDrive.DvdMediaType -eq "ISO") 
        Write-Host "Removing ISO from" $VMDrive.VMName
        Get-VMDvdDrive -VM $VM | Set-VMDvdDrive -Path $null

Just run this PowerShell code in the cluster, and ISO files will be ejected from all virtual machines in the cluster.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.