Finding used ISOs in Hyper-V

27 August 2013

I have currently 23 guest VMs on my Hyper-V machine, whenever I set up a new VM, I have a script to create an ISO with my latest tools to be used in the new VM. The script hangs when it tries to delete the previous ISO file, because an older VM has still mounted the ISO.

The following line of PowerShell gives me a list of all VMs which still have ISOs mounted:

Get-VM | Get-VmDVDDrive | where {$_.DVDMediaType -ne "None"} | select vmname, path
Now I can unmount them manually or by using another PowerShell line to unmount all:
Get-VM | Get-VmDvddrive | where {$_.DVDMediaType -ne "None"} | Set-VMDvdDrive -Path $null

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows