This might sound a bit strange, I mean why would you want to do that? Well this requirement came up during a vCNS to NSX upgrade in a vCD environment. In particular when hosts needed to be put into maintenance mode to allow the new VIBs to be installed/upgraded.
Before a host is put into a vSphere maintenance mode, it should be disabled in vCloud Director so that vCloud Director does not try to schedule tasks on the host and that’s where the problem manifested itself: if a single VM has a media attached the host will simply not be evacuated. So you need to go and figure out which virtual machine still has a catalogue media (iso) attached.
In the past weeks I have spent a lot of time automating “things” using #PowerShell and I must admit it’s a lot of fun so that was going to be my next job!
So here’s the link to the script on GitHub https://github.com/giulianoberteo/vcdEjectMedia
Again feel free to improve it 😉