Powershell / PowerCLI Script to List & Unmount ISO on VMWare VMs prior to VxRail 4.5 or 4.7 upgrade

Posted by

In the past I have spoken about needing to remove mounted ISOs from VMs prior to a VxRail upgrade. I have had many people DM me asking if I use a script or do it manually. First, it would only be possible in a small environment to manually remove mounted ISO files or in environments that only have a couple. For enterprise environments, I use a powercli script. I wanted to take a moment to list the strings I use and allowyou to put them into your own script.

I wanted to give credit to Tomas Kalabis who posted the strings:

How to get the VMs with mounted ISOs:
Get-VM | Get-CDDrive | select @{N=”VM”;E=”Parent”},IsoPath | where {$_.IsoPath -ne $null}

If you want to export it to a csv then:
Get-VM | Get-CDDrive | select @{N=”VM”;E=”Parent”},IsoPath | where {$_.IsoPath -ne $null} | Export-Csv -Path “E:\Temp\VMs_ISOs.csv” -NoTypeInformation -UseCulture

If you want to unmount the ISOs
Get-VM | Get-CDDrive | where {$_.IsoPath -ne $null} | Set-CDDrive -NoMedia -Confirm:$False

A couple moving parts that make it a little work. However, it is far less work than if you had to do it manually. As always, I hope y’all found this useful.

One comment

Leave a Reply