Search This Blog

Monday, April 1, 2013

Dismount ISO or DVD From the VM By Using Powershell


Getting a bit tired of checking which VMs are having iso mounted and still cannot figure out why people forget to dismount the iso from the VM after using it.

Imagine you got 20 , 30, 40 or 100 VM in your environment. Are you going to use GUI to check each one of them. Well, I’m a bit lazy so the faster way to achieve this is by using Powershell.

Get-VMDvdDrive –Vmname *

This will display the entire VM which is connected to DVD. For those VMs that is not connected to iso will be displayed as “None” on the DvdMediaType Path. My example below shown 2 VMs are connected to iso and listed Controller Number and Controller Location of the DVD Drive.


Next step, how to remove the iso/dvd the faster way without using GUI after identified which VMs having the iso?

Set-VMDvdDrive –VmName Red-SQL –ControllerNumber 1 – ControllerLocation 0 –Path $null


The command will connect to the VM and eject the DVD/iso from the VM.

View the result again by typing the command Get-VMDvdDrive


Thanks to Powershell, I can faster dismount the DVD/ISO from the VM.