PowerShell oneliner – Unmount ISO files in Hyper-V or SCVMM

An ISO is mounted when you install the Hyper-V Integration Tools … but not unmounted when the installation is finished. So whenever I go to a customer for migrations or maintenance on a Hyper-V (SCVMM) environment, I always dismount those ISO’s.

Doing this manually takes a lot of time and is a task that kinda sucks… So, let’s use my favorite tool for that: PowerShell.

The following script will dismount all ISO images:

Get-VirtualDVDDrive -VMMServer $VMMServer -All | Where-object {($_.ISO -ne $null) -and ($_.ISOLinked -eq $false)} | Set-VirtualDVDDrive –NoMedia

But what if you would only like to dismount the Hyper-V Integration Tools ISO and leave the rest intact?

Get-VirtualDVDDrive -VMMServer $VMMServer -All | Where-object {($_.ISO -ne $null) -and ($_.ISOLinked -eq $false) -and ($_.ISO -like ‘vmguest’)} | Set-VirtualDVDDrive -NoMedia

2 comments

  1. Luke Walker says:

    For the dismounting of just the Hyper-V Integration Tools ISO, wouldn’t you just do … | Where-Object {($_.ISO -like ‘vmguest’)} | .. are the .ISO -ne $null and isolinked checks necessary?

  2. Jeff Wouters says:

    Hi Luke,
    Necesarry, definitely not in this case since I define ‘vmguest’ later on. So you could just as easily remove that part.
    Thanks for your feedback, it’s a good one!
    Jeff.

Leave a Reply

Your email address will not be published. Required fields are marked *