Rss Feed Tweeter button
VMware vSphere PowerCLI Reference - Automating vSphere Administration
VMware vSphere PowerCLI Reference

PowerCLI Book: Download Scripts, Functions and Modules

This book is obviously full of a tonne of PowerCLI examples for you to use - naturally though you will not want to type them all out from the book yourself after reading them! So each script and function is available for download on a per chapter basis from the Resources and Downloads section of the book's home on the Sybex website .

Whilst this could be handy if you want to use a few or even just one function from a chapter, there are 23 chapters worth of files to download if you want everything. So we have combined all the functions into a single PowerShell module from which you have access to everything. If you are not familiar with PowerShell modules yet PowerCLI book author Jonathan has written and introduction to get you up to speed -

However, to start using the PowerCLIBook module this is what you need to do:

  • Extract the zip file and copy the PowerCLIBook folder containing the 4 files that make up the module to your PowerShell modules file location, typically this will be C:\Users\username\Documents\WindowsPowerShell\Modules


The module is made up of four files:

  • PowerCLIBook.psd1 - The PowerShell module manifest file, which describes the contents of the module and controls how the module is processed.
  • PowerCLIBook.psm1 - The PowerShell module file containing the functions which make up the PowerCLIBook module.
  • DistributedSwitch.psm1 - The PowerShell module file containing the functions which make up the DistributedSwitch nested module, if you like a sub-module of the PowerCLIBook module.
  • Test-Version.ps1 - A script which is run prior to the PowerCLIBook module being called which checks to see if PowerCLI 4.1 or newer is installed.


  • From your PowerShell session you will now be able to see that the PowerCLIBook Module is available:

Get-Module -ListAvailable

  • To use functions from the module it needs to be imported into the current session:

Import-Module PowerCLIBook

  • To view what functions are now available (in total there are 79!):

Get-Command -Module PowerCLIBook

  • To view the comamnds specific to Distributed Switches:

Get-Command *DistributedSwitch*

  • To get help on one of the functions:

Get-Help Set-DistributedSwitch -Detailed

  • To view the help examples for a function

Get-Help Set-DistributedSwitch -Examples

We hope you find this a useful way to access the scripts and functions from the book.


PowerCLI Book Competition on Planet VM

VMware vExpert and general virtualisation legend Tom Howarth has very kindly decided to give away an additional copy of VMware vSphere PowerCLI Reference that he has spare. All you need to do to be in with a chance of winning is submit a PowerShell based script via Tom's site and Jonathan will pick a winner to receive the book. Full details from Planet VM:


I’ve received a copy of VMware vSphere PowerCLI Reference as a review copy, but I have already purchased one.  So I have one to give away.

At the last London VMUG I was speaking to Jonathan Medd one of the authors, and he suggested that I organise a competition for the thing the winner receives my spare copy of the Book.  So I thought that a PowerShell competition would be a nice way of sorting out the winners, but then with my level of programming / scripting skills (think have difficulty to create “Hello World”) I would not be able to tell a good script from a shopping list for Tesco’s (or if American “Walmarts”)

This is when the Jonathan jumped in to the rescue and said he would judge it.  Well I thought WOW.

So here is the rub,  Do you want a free copy of VMware vSphere PowerCLI Reference, well then write a PoSH script that Mr Medd likes and its yours.

To enter the competition simply upload your script to the following location


You will have until the beginning of VMworld Vegas to upload your scripts and the winner will be announced on the 5th September.

Note, LucD, Alan Renouf, et all will be disqualified, to allow us mere mortals a chance :D


Kindle Version Available Again!

KindleThe question that we have been asked the most since the PowerCLI book was published is "When is the Kindle version going to be available?" As you may or may not be aware it was briefly available back in April, but there was an issue with the formatting of the code which meant that it had to be pulled and corrected. Whilst we were initially told that it would be a 1 - 2 week wait to be corrected, due to other issues the publisher was experiencing with Kindle versions in general, it has taken until now for it to be made available again. However, the book is now back in Kindle stores and the code issue has been corrected.

The question we have been asked the second most was back in April, "Why is the Kindle version more expensive than the paperback?". At the time we went back and forth with both the publisher and Amazon and received conflicting answers. Well now that is back in the various Kindle stores again, this situation also seems to have improved and typically it is slightly less than the paperback in price. (In April on Amazon UK the Kindle version was £10 more expensive than the paperback)

--------------------  Kindle     Paperback

Amazon US            $27.65 $31.45

Amazon UK           £17.22 £19.13

Amazon Germany     €28.72 €38.30

We apologise for the length of time to get this back into Kindle, but hope you will be pleased it is finally ready!

Filed under: Book No Comments

PowerCLI Book Summer Holiday Competition

It's time to launch a new PowerCLI Book competition.

Since most of you are soon leaving for a well-deserved holiday, we wanted to send you on your way with a new PowerCLI Book competition. This time we want to see pictures of the PowerCLI Book with well-know landmarks in the background.

So if you are visiting Hoover Dam,

the Vatican,

Death Star

or any other well-know location, make sure to take a picture of the landmark with the PowerCLI Book in it.

If you have an electronic version of the PowerCLI Book, use your reader with the title page visible in the picture.

The competition will run till midnight CET August 25th 2011 . This should give you ample time to come up with a fabulous picture, and will give us the time to announce the winner before VMworld 2011 US.

The winner will receive a price that he/she can surely use and enjoy when using PowerCLI, PowerShell and vSphere!

Upload your pictures to this post on the PowerCLI Book forum or send them as an email attachment to this address.


An interview with the first PowerCLI Book raffle winner

On Monday April 11th. we announced Daniel Hayward as the winner of our first PowerCLI Book raffle. We thought it would be nice to post a small interview with our winner and Dan luckily agreed. Read all about our lucky winner and how he utilizes PowerCLI in his daily routine as both a time-saver and to make his job a lot easier.


Hi Daniel,
can you introduce yourself to our readers please?

I'm 27 years old, married with a 6 month old son. I've been working in IT for over 10 years, starting at the bottom building custom order PC's and working my way up ever since. I've been working with VMware products for about the last 3 years or so, and haven't looked back since.

Where do you work and what’s your role?

I currently work for an IT reseller and integrator called Alchemy Systems International Limited based in Surrey, UK. I'm the Technical Team Leader at Alchemy and my role mainly involves looking after our hosted desktop environment which we've now been running and expanding for some time now, as well as designing and implementing VMware (and traditional) environments for our clients. I'm also responsible for our internal network systems and adding new products to our hosted (IAAS) solutions. As well as this, I also help to manage the technical team with any escalated support requests.

When did you first heard about PowerCLI?

I first heard of PowerCLI just over a year ago whilst taking an updated vSphere course for a week, and, having used PowerShell for managing Exchange servers for a couple of years I jumped at the chance to see what I could do with the PowerCLI. Since then it's been a massive learning curve, and one I'm thoroughly enjoying, especially recently with the work I've been doing trying to manage our systems with much more ease.

Since when have you been using PowerCLI?

Pretty much since I first heard about it on the vSphere course. That night I downloaded it onto our vCenter server, and my laptop and started taking a look at what I could do with it. Starting with simple tasks like listing all of the VM's in one of the clusters.

How does PowerCLI fit into your daily routine?

These days I'm using the PowerCLI a lot. And I mean a lot. In the last week I've written several new scripts, some for deployment of new/recreated vSphere environments and others for gathering requested information into CSV files for customers.

Do you use PowerCLI using PowerGUI or using the command line?

I use the PowerCLI entirely from the command line, I've not even looked at the PowerGUI yet, though it is on my to-do list! If it makes PowerCLI even easier, and even faster, then I'm all for it!

Did you ever used any of the scripts of the authors in your environment?

Absolutely! I came across Luc Deken's vDS functions several months ago, and have been following him on Twitter ever since. I've used those functions several times in scripts for our environments, and, since the book arrived just several hours ago, I've already used the vDS scripts to let us re-create our vDS config if needed, straight from CSV files that I exported using PowerCLI!

Did you ever used PowerCLI as a time-saver in your environment?

I've used PowerCLI to save time all over the place. We've now setup scripts to deploy an IAAS environment for a customer from a pre-built set of templates we created.

What’s the coolest thing you’ve ever realized using PowerCLI?

All sorts, especially our deployment script for the Hosted Desktop solution we have. This is probably the longest script I've written so far and saves about an hour of time each time it's used, but the most recent realization was that I could potentially script the entire setup of a VMware infrastructure from a single script file.

Are there any tasks you’re planning to use PowerCLI for in the future?

Loads! My next plan is to get a script written to add a host into vCenter and set all of the config we use automatically, it'll save me hours each time we add a new host or two to a cluster, and I could then always "convert" it to run on client builds too.

Thank you Daniel.

You can follow Daniel on twitter @DanPHayward, or visit his blog at

Tagged as: , No Comments

PowerCLI Book Raffle – Winner Announcement

Thank you very much to everyone who participated in our PowerCLI Book Raffle. To collect all the Re-Tweeted messages we obviously used PowerShell code.

Thanks to Eric Sloof it was quite a job to include all messages as he mutilated the original message by using TwitLonger. This resulted in the #MagicTweet hashtag getting lost in his message and in the messages of everyone who Re-Tweeted Eric's message. Thank You Eric! Because it wasn't a strict requirement to include this hashtag we decided that those messages were eligible to enter the raffle too.

After collecting all the messages, we have selected a winner using PowerShell's Get-Random cmdlet.

Finally, the moment we have been waiting for:

The winner of the first PowerCLI Book Raffle is .... Drum Roll Please!

Daniel Hayward (@DanPHayward)

Congratulations Daniel! We'll make sure that your PowerCLI book will find its way to you.

Filed under: Book 1 Comment

Kindle version now available


Now available on the Amazon US and Amazon UK sites is a kindle version of our book and remember if you have an iPad or iPhone you can also download the Kindle app for free and take our book on the road !

Prices are currently higher than the paper back version of the book but these are unfortunately not under our control.

If you are still unsure if you need this book then make use of the sample view which Kindle allows you to download and read.

Be aware

There is currently an issue with the code formatting on the kindle version which will replace the double quotes with ″ the publisher is working on this issue and an updated version should be available soon.

In the meantime don't forget that the code can be viewed from the link found in the book and this is probably an easier way to look at it when using a PowerShell editor.



We have now had an update from Sybex that the above mentioned issue will be fixed within 2 weeks, confirmation of how to download a newer version will be added as more information is gained.

Filed under: Book 11 Comments

PowerCLI Book Raffle

Most projects have to start somewhere as an idea, and this one was no different. When Sybex contacted us, our idea suddenly became a reality and now after quite a journey, our book has finally arrived. Because most of the content of this book is inspired by the PowerCLI community, we decided to give something back. To celebrate the release of our book, we're organizing a book raffle. Read the instructions below and enter the draw for a chance to win a free copy of "VMware vSphere PowerCLI Reference: Automating vSphere Administration".

The Book

Before you enter the draw, we think it's important that you know what there is to win.

If you manage vSphere in a Windows environment, automating routine tasks can save you time and increase efficiency. VMware vSphere PowerCLI is a set of pre-built commands based on Windows PowerShell that is designed to help you automate vSphere processes involving virtual machines, datacenters, storage, networks, and more. This detailed guide—using a practical, task-based approach and real-world examples—shows you how to get the most out of PowerCLI's handy cmdlets.

Learn how to:

  • Automate vCenter Server and ESX/ESX(i) Server deployment and configuration
  • Create and configure virtual machines and use vApps
  • Secure, back up, and restore your virtual machines
  • Monitor, audit, and report the status of your vSphere environment
  • Use the PowerCLI SDK, PowerWF Studio, and vEcoShell
  • Schedule and view automation
  • Add a GUI front end to your scripts

The Authors

Luc Dekens, VMware vExpert, has worked with operating systems for over 20 years and now focuses on virtualization, particularly platforms produced by VMware. He blogs about PowerCLI and the vSphere SDK at

Alan Renouf, VMware vExpert, is an EMC vSpecialist and has been working with VMware, Citrix, and Microsoft products for several years. Currently he focuses on virtualization products and their automation using PowerShell. He is also cohost, along with Jonathan Medd, of the Get Scripting podcast ( Alan blogs at

Glenn Sizemore, VMware vExpert, started scripting early in his IT career, adopting PowerShell early on and conquering it when VMware PowerCLI first shipped. He shares scripts and automation techniques on his blog at

Arnim van Lieshout, VMware vExpert, has been in the IT industry for 12 years, working mainly with operating systems. He has been focusing on virtualization for the last five years, especially automating tasks using PowerShell. Arnim blogs at

Jonathan Medd, PowerShell MVP, is cohost of the Get-Scripting podcast and also shares his PowerShell knowledge at

The Site

We welcome feedback from you about this book. We've developed a message board for everything related to the book at Stop by and let us know how we did, check for updates, and join the discussion. If you have specific questions, send us a message at You can also contact each of us through our blogs.

The Rules

  • Follow us on twitter and watch for the magic message that one of us will release on Monday April 4th.
  • In order to enter the draw just Re-Tweet (RT) the magic message.
  • The deadline is Friday April 8th 23:59 CET.
  • One lucky winner will be drawn and published on this site on Monday April 11th and will also be announced on Twitter.

That's all folks, Good Luck!!!

Tagged as: 9 Comments

Publication date March 28th 2011

We just received word from our publisher.

"The book will be releasing from our warehouses on March 28th which means that books should reach stores/resellers a week later."

Filed under: Book, Update 2 Comments

PowerCLI Book Table of Contents

Now that the book is nearly finished, we present to you the Tabel of Contents (TOC) so you can get an idea of what to expect to be covered in our upcoming PowerCLI book. If you think this book is of great value to you after reading the TOC, you can already pre-order your copy now. So make sure you're amongst the first individuals to receive a copy of what we think is a valuable resource if you're into PowerCLI.

Secure your first edition collector's item now at these stores:

Amazon (US)
Amazon (UK)
Amazon (DE)

This table of contents is subject to change on actual release.

VMware vSphere PowerCLI Reference:
Automating vSphere Administration

Paperback: 504 pages
Publisher: Sybex (April 12, 2011)
Language: English
ISBN-10: 0470890797
ISBN-13: 978-0470890790

Part I: Install, Configure and Manage the vSphere Environment

Chapter 1        Automating vCenter Server Deployment and Configuration
Chapter 2        Automating vSphere Hypervisor Deployment and Configuration
Chapter 3        Automating Storage and Networking
Chapter 4        Using Advanced vSphere Features

Part II: Managing the Virtual Machine Life Cycle

Chapter 5        Creating Virtual Machines
Chapter 6        Using Templates and Customization Specifications
Chapter 7        Configuring Virtual Machine Hardware
Chapter 8        Advanced Virtual Machine Features
Chapter 9        Using vApps

Part III: Securing Your vSphere Environment

Chapter 10      Backing Up and Restoring Your Virtual Machines
Chapter 11      Organize Your Disaster Recovery
Chapter 12      Hardening the vSphere Environment
Chapter 13      Maintain Security in Your vSphere Environment

Part IV: Monitoring and Reporting

Chapter 14      Reporting the Status of Your vSphere Environment
Chapter 15      Using Statistical Data
Chapter 16      Monitoring the vSphere Environment
Chapter 17      Auditing the vSphere Environment

Part V: Scripting Tools and Features

Chapter 18      Scheduling Automation Scripts
Chapter 19      The SDK
Chapter 20     The Onyx Project
Chapter 21      PowerGUI and vEcoShell
Chapter 22      PowerWF Studio
Chapter 23      Adding a GUI Front-end to Your Automation Scripts

Filed under: Book, Update 11 Comments