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

Again feel free to improve it 😉

Happy #automation!

Be sociable, share!Tweet about this on TwitterShare on LinkedInShare on FacebookShare on Google+Email this to someone

Leave a Comment

Your email address will not be published.