Automate media eject for all vCD VMs

eject-vcd-mediaThe Problem

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.

Now if you have a lot of hosts and hundreds of
VMs you don’t want to do that manually do you?
shut-up-automate-it

The Solution

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

****** UPDATE 06-Nov 2020 *******
I have created a new branch to work with vCD 9.7 and API version 32.0. In order to have it working with this version I had to temporarily disable the ISO lock warning as well as the auto answer message VM advanced setting on all virtual machines.

Again feel free to improve it 😉

Happy #automation!

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Trackbacks