Skip to content

Unmount VM-ISOs after days

I had a minor issue with lingering ISOs in an VMM-environment. The issue wasn’t a technical one but a “soft” one. The users admins of the environment did not unmount ISOs after usage. So I created a small script that is triggered once a day and unmounts all ISOs that is more than a week old.

$VMMServer = "yourVMMServer"
Get-VirtualDVDDrive -VMMServer $VMMServer -All | Where-object {($_.ISO -ne $null) -and ($_.ISOLinked -eq $false) -and $_.addedtime.date.adddays(7) -lt (get-date)}| Set-VirtualDVDDrive –NoMedia

There is no magic in this script. It does just what it looks like. Iterate through all Virtual drives and gets the “addedtime” and checks if it older than 7 days. If so set virtual drive to -null.