Spinning Gold with the PowerCLI Cookbook


One of the more difficult parts of learning PowerCLI – and PowerShell itself – is determining where to get started. I often suggest identifying a project or task that you want to complete, and then figuring out how to do it, because aimlessly fiddling with a language can be frustrating. If you’re looking for a library of sample code that walks you through the why and how, I’d suggest picking up the PowerCLI Cookbook written by Philip Sellers.

The book is published through Packt Publishing, who’s library contains material that wildly varies across the quality spectrum. However, it is obvious that Philip put a large quantity of time, effort, and care into this book and offers over 200 pages of in-depth discussion and examples for automating a wide swath of data center activities.

Each walk-through is arranged into a recipe, containing details on:

  • What will be required to follow along with the recipe.
  • Steps required to build the code.
  • Details on why the code is setup the way it is (and how to modify it for your own purposes).

The author has frequently added additional reading to the recipes with blog links, documentation, KBs, and other handy resources.

Snazzy Content Alerts

Of note, Philip has built a fairly robust set method for balancing share allocations and resource pools using some of my older work as a baseline. Don’t worry, he pinged me about it before it made it into the book, but his approach of using a custom attributes (page 140) is refreshing and looks solid. He even writes a proper function whereas my code was just a spitball idea.

There’s also an entire section on snapshot management (page 107) with the steps necessary to build a snapshot management module (page 129). I’ve talked about PowerShell modules recently, and it’s spectacular to see examples on building custom modules in this book. Philip offers ideas around naming of snapshots, when to quiesce memory, and how to automate / prune the snapshot lifecycle. This is solid stuff.

The last thing I’ll compliment is the points in the book where Philip goes a bit out of scope of a straight cookbook. For example, on page 78 there’s a decent volume of content covering the use of Get-View and how to view properties and methods. That’s some pretty advanced stuff, but the writing breaks it down into meaningful and digestible chunks. Having hit the limitation of the native PowerCLI cmdlets frequently, there’s definitely a lot of value in knowing how to leverage methods directly.

Get It!

If you’re brand new to PowerCLI, or looking to leverage some polished examples to help tickle the noodle on coding ideas, I’d suggest picking up a copy of PowerCLI Cookbook. I read the whole thing over the course of a few plane flights because it was that good.