Use PowerCLI to find all VMs with a mounted ISO file as a CD/DVD drive

Power CLI

I was doing some maintenance and wanted to clean up some old NFS mounts we had on our ESXi server. Here’s a one-liner you can slap in PowerCLI once you are auth’d to vCenter. It will essentially list all VMs that have an ISO mounted. Pretty easy! I was then able to umount the CD/DVD ISO on the appropriate VMs so I could umount the NFS share clean.

Get-VM | FT Name, @{Label="ISO file"; Expression = { ($_ | Get-CDDrive).ISOPath }}