These VMware PowerCLI commands, came in handy a month or so ago. I’d thought I’d share. Credit is given in the links below.
What do you do when, you see a mounted ISO not being used? Left abandoned and discarded? Does it drive you absolutely mad? Do you go all stabby Joe? Does the OCD kick in and you need to find and unmount the entire world. Then the below may help.
In all seriousness though, a mounted ISO will cause a VMotion to fail.
Get-VM | Where-Object {$_ | Get-CDDrive | Where-Object { $_.ConnectionState.Connected -eq "true" } } | Select-Object Name
Get-VM | Where-Object {$_ | Get-CDDrive | Where-Object { $_.ConnectionState.Connected -eq "true" } } | Get-CDDrive | Set-CDDrive -Connected $false -Confirm:$false
Get-Cluster 'Cluster 1' | Get-VMHost | Get-VMHostStorage -RescanAllHba -RescanVmfs