...Because someone's gotta tell the story...


To return to the main Blog List, click Full Blog Listing.


Site Updates

Finding that ISO in a VM with PowerShell

Wednesday, August 10, 2016 in Powershell (Views: 2159)
Every once in a while, you forget that you mounted an ISO file into a VM. You may try to copy or move it, only to find the file in use.

Even in a lab of 2 hosts and 20 VM's, finding that nasty ISO mount can be an ugly thing, so a simple PowerShell to remedy it. First, you can use this to actually query the server and find which VMs have an ISO mounted...

Get-VM | Get-VMDvdDrive | Select-Object VMName, DvdMediaType,Path | Where-Object dvdmediatype -eq "ISO"

If you want to unmount any ISO at this point, in my case all, you can issue this command:
Get-VM | Get-VMDvdDrive | Where-Object dvdmediatype -eq "ISO" | Set-VMDvdDrive -Path $Null
This will unmount any ISO attached to any VMs on this host.

For those looking for that quick fix, hope this helps.


Related Blogs You May Be Interested In:

To leave a comment, please log in and/or register.