How to Create and Populate a vSphere Content Library with PowerCLI

“Automate the boring stuff”- it’s the title of the most recommended Python book for new programmers, but it’s also how I feel about all things that I have to do more than a couple times.

My general rule is if it takes less time to write a script to do it, than to do it manually a few times … then I write the script.

One of the things I have been doing a lot lately is building new lab environments, and then uploading all the Windows and Linux ISO files so that I can create VMs. Each ISO takes like 5 clicks to get it into a VMware Content Library. That is a lot of clicks when you upload 20+ ISOs to each lab environment.

PowerCLI to the Rescue

Starting with PowerCLI 11 or 11.5, they added some cmdlets to work with Content Libraries. So I created a script to use them.

You can find the script on GitHub here.

https://github.com/recklessop/vmware-content-library-builder

This script will create a Content Library, or add content to an existing one if it already exists.

It also checks to see if the ISO is already in the library, if it is it will skip over it, which means this script could be ran programmatically to sync a library to a folder.

It’s pretty fast too, I was getting 500Mbps, I haven’t tried to make it multi-threaded but that might make it even faster. Maybe that’s version 2.0 🙂

Let me know what you think, and if you have any contributions/bug fixes please submit a pull request to the Github repo.

Loading

Share This Post

Post Comment