PowerCLI 5.0 has new cmdlets and PowerShell snap-ins that are real timesavers for VMware administrative tasks....
While some of the additions are targeted specifically for vSphere 5, PowerCLI 5.0 also adds functionality to vSphere 4. Let’s take a look at just some of the new and cool things you can do with PowerCLI 5.0 cmdlets and PowerShell snap-ins.
Background on PowerCLI 5.0
Before downloading PowerCLI 5.0, I highly recommend that you take a look at the release notes, because there are some PowerCLI changes that may affect your infrastructure, in addition to a long list of known issues with this release.
For a complete outline of all the PowerCLI changes, consult the VMware vSphere PowerCLI Change Log. And, of course, the vSphere PowerCLI Overview is also a good read, unless you’re like me and use the Get-Help cmdlet with the detailed parameter.
To start, some PowerCLI 5.0 improvements help make scripts shorter and less complex, which will make your job easier. The new Get-VIProperty cmdlet is definitely welcomed, for example. It shows all of the extended properties that were difficult to find in the past versions, such as the VM description and notes. This information is more detailed than basic properties like VM name, power state, number of CPUs and amount of memory.
The Get-VIProperty command lays out all of the available information in an easy-to-read format. The PowerCLI sessions at VMworld 2011 placed a strong emphasis on using extended properties, and the Get-VIProperty promises to open more advanced scripting capabilities to the average administrator.
There are other cmdlets and cmdlet parameters that offer more flexibility and can help you create powerful scripts:
- Get-VMHostAuthentication and Set-VMHostAuthentication: These cmdlets join your hosts to Active Directory domains on the fly.
- Copy-VMGuestFile: This cmdlet allows a script to copy files and/or folders to and from the guest OS, which is great for executing mass updates and changes to VMs. It also works in vSphere 4 infrastructures.
- New-Template: This cmdlet creates a clone of an existing template, which you can use for automated build scripts. (I, however, prefer using Microsoft Deployment Toolbox for automated OS builds. It offers much greater flexibility and does not require the post-deployment tasks that templates in vSphere require.)
- Get-VIAccount: This cmdlet lists all of the IDs that have access to a vCenter or ESXi host. It’s very useful when performing security audits or vCenter migrations when used in conjunction with the Get-VIRole cmdlet, which lists all of the roles that are defined in your vCenter.
- New-VM: This cmdlet isn’t new, but the updated –ResourcePool parameter now accepts a cluster name as an option, which greatly eases the automation and placement of new VMs. Be aware that the new Get-Template cmdlet does not allow a parameter for VM placement in a cluster, but the New-VM cmdlet will do the trick.
New PowerShell snap-ins
PowerCLI 5.0 introduced three, new vSphere PowerShell snap-ins, extending PowerShell functionality to other tools. The new PowerShell snap-ins center around new features of vSphere 5, mainly Auto Deploy and Image Builder. (Eric Sloof at has an excellent slide deck on the those features.)
Be sure to add the followingsnap-ins to your PowerShell profile:
- VMware.ImageBuilder: As an integral piece of the vSphere Auto Deploy feature, this snap-in allows for the creation of custom ESXi images and media that you can launch with Auto Deploy. You can also use these images as standalone installation media, without the Auto Deploy functionality.
- VMware.DeployAutomation: This snap-in contains cmdlets that provide an interface to the VMware Auto Deploy feature, which you can use to easily build and create new ESXi hosts. (.)
- VMware.VimAutomation.License: This snap-in provides detailed license information about your infrastructure, which is especially useful with the new vRAM requirements and limitations. It also works with vSphere 4 infrastructures. The Get-LicenseDataManager cmdlet in this snap-in can retrieve, create, modify and remove licenses.
Overall, PowerCLI 5.0 is a hands-down winner. The new cmdlets, snap-ins and parameters make for a more complete and robust scripting command-line interface that all administrators can use in their vSphere environments. PowerCLI will always be a part of my daily admin life, and I’m sure it will be part of yours, if it isn’t already.