Wednesday, May 1, 2013

How to see what VM's have a DVD/ISO file mounted and how to mass unmount the DVD/ISO files

This has now been added to pshvm.codeplex.com a free powershell hyper-v manager project.

To find what vm's have a DVD/ISO mounted
From with Powershell type
get-vmdvddrive -vmname *

it will list like this
VMName               ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------                        -------------- ---------------- ------------------ ------------ ----
TEST1                     IDE            1                0                  ISO          C:\baseimages\WindowsS...
TEST                       IDE            1                0                  None

To mass unmount/eject the DVD/ISO file
From with Powershell type
get-vmdvddrive -vmname * | set-vmdvddrive -path $null

it will list like this
VMName               ControllerType ControllerNumber ControllerLocation DvdMediaType Path
------                        -------------- ---------------- ------------------ ------------ ----
TEST1                     IDE            1                0                  None
TEST                       IDE            1                0                  None

To add insert a DVD into a VM with Powershell:
To insert the MS Integration Tools ISO type (substitute tools ISO path for the ISO you wish to insert)
Set-VMDvdDrive -VMName Test1 -Path C:\Windows\system32\vmguest.iso

To eject any ISO from the DVD type 
Set-VMDvdDrive -VMName Test1 -ControllerNumber 1 -ControllerLocation 0 -Path $null


No comments:

Post a Comment