After having a quick look at the blog, I noticed that it had been a while since we talked about PowerCLI here. PowerCLI is the scripting tool of choice of many VI admins out there and for a good reason. It is easy to use thanks to PowerShell’s simple syntax, very powerful as it integrates with most VMware products, and extensible if you need to interact with third-party products like IPAM or load balancer solutions.
The options and possibilities are endless with PowerCLI, especially given the fact that VMware keeps on updating and improving it over the years. It feels like yesterday when PowerCLI 6.5R1 changed the way the module is installed. As of 2022, we are now at PowerCLI major version 12 which was released back in 2018. However, we will still have a look at what features it brought over the minor versions.
The previous major version was released all the way back in 2018 which we also covered in the blog.
PowerCLI 12 main changes
First of all, let’s start with PowerCLI 12.0 which was released over 2 years ago. It came with a massive amount of new functionality, support for newly released products, and performance improvements. Note that I will talk about new additions with no regards to the minor version as we expect you’ll be installing the latest one. Not that this is important but among the changes was a shiny new logo to go with the new product branding.
Added cmdlets for ESXi host network management, HCX, Namespaces, Trusted Host Services, VM Guest Disk, VMware Cloud on AWS, and additional vSAN cmdlets. On top of that, a new module was added for VMware Cloud Services management and updated support for newer versions.
A few quality of life improvements found their way into the release such as cmdlets for managing vSphere hosts network stacks when you need different default gateways so the VMKernel can route that traffic throughout the network. But let’s have a look at a few other changes.
Guest disk management
Guest disk management was the most anticipated feature where you can map virtual disks to guest OS volumes. As someone who’s needed it very much in the past and wrote functions to get a somewhat homemade version of it, I have to say I was pleasantly surprised to find that feature which is awesome. I expect it will make its way into many VI admins’ reporting scripts.
- Get-VMGuestDisk
Support for PowerShell 7
PowerShell 7 is what used to be called PowerShell Core and is the latest version of the command line utility that is now cross-platforms on Windows, Linux, and macOS. Note that more than 40% of PowerCLI users are on Linux and macOS! I won’t get into the changes between PowerShell 6 and 7 but you can find that information over there
PowerCLI 12 is the first version that supports PowerShell 7. Along with this added support, note that VMware has deprecated support for both vSphere 6.0, Windows PowerShell 5 or older, and PowerShell Core 6.
“Foreach-object -Parallel” support
If you are used to iterating over large numbers of objects in PowerCLI with Foreach loops, you will know how frustratingly slow it can get at times. There are ways to process asynchronously but it can get a bit messy and cumbersome when all you want is to run a bunch of tasks in parallel and you’d rather smash the CPU for 2 minutes rather than wait 10 for it to finish. Enters Foreach-object -Parallel, a new parameter introduced in PowerShell 7 for parallelizing work. You can even use the -ThrottleLimit parameter to reduce the impact on your machine.
Manage vSphere Lifecycle Manager
One of the major changes brought by vSphere 7 was vLCM or vSphere Lifecycle Manager, an alternative way to vSphere Update Manager to manage updates, patches, drivers, firmware… While VUM has been around for a very long time, vLCM is still fairly new and often misunderstood in how it works.
PowerCLI 12 brings cmdlets to manage vLCM natively such as Get-LcmImage, Test-LcmClusterCompliance, Test-LcmClusterHealth, Export/import-LCMClusterDesiredState and more. Along with them came parameters and properties relating to it added to cluster cmdlets and objects.
Organization and user management
While this went somewhat under the radar, I very much appreciated finding out that PowerCLI 12 adds user management capabilities for those using VMware Cloud Services. Although this isn’t going to be useful for all customers, I can see the value in programmatic checks for reporting or auditing purposes for instance.
- Connect-Vcs
- Get-VcsOrganizationRole
- Get-VcsService
- Get-VcsServiceRole
- Get-VcsUser
- Get-VcsUserInvitation
- New-VcsUserInvitation
- Remove-VcsUser
- Remove-VcsUserInvitation
vSphere Automation API SDK Module
Although it happens underneath the surface, PowerCLI 12.4 brought significant changes as it added additional API binding for accessing the vSphere REST APIs. These new bindings simplified interactions with vSphere REST APIs and provide PowerShell native user experience.
A new manifest module called ‘VMware.Sdk.vSphere’ contains a bunch of sub-modules for all the REST APIs available for vSphere. These are essentially low-level PowerShell functions to help you deal with methods and data structure. More information on how to use it in the doc
vCenter Server Appliance Service Management
Among the new capabilities of PowerCLI 12, you will also find cmdlets to manage the vCenter Server Appliance (VCSA) itself. While those are not operations you typically deal with on a daily basis, having the option to do so will open possibilities to VI admins. One of the use cases I can think of gravitates, once again, around custom reporting and alerting.
- Get-VIApplianceService – Retrieves vCenter Server Appliance Services
- Start-VIApplianceService – Start vCenter Server Appliance Service
- Stop-VIApplianceService – Stop vCenter Server Appliance Service
- Restart-VIApplianceService – Restart vCenter Server Appliance Service
On top of that, some more helpful cmdlets include interactions with the configuration of VCSA backups.
- New-ApplianceBackupJob : This cmdlet starts a file-based backup job for a vCenter Server system to a backup server
- Wait-ApplianceBackupJob : This cmdlet monitors the progress of a backup job and returns the ApplianceBackupJob
- Get-ApplianceBackupJob : This cmdlet retrieves a list of finished or currently running backup jobs
- Stop-ApplianceBackupJob : This cmdlet stops a list of running backup jobs matching the specified parameters
- Get-ApplianceBackupPart : Retrieves a list of parts that can be included in a backup job, and their estimated backup size. Non-optional backup parts are always included in the backup
vSphere Native Key Provider
vSphere 7 Update 2 introduced vSphere native key providers to offer a way to enable data-at-rest protections like vSAN Encryption, VM Encryption, and vTPM straight from vSphere itself. This means customers can leverage this mechanism within vSphere itself without needing a fully-fledged Key Management Service (KMS).
PowerCLI 12 lets you manage the native key provider feature like:
- Get-KeyProvider
- Export-KeyProvider
- Import-KeyProvider
You can use the key providers to set encryption with the -KeyProvider parameter on the likes of Set-VM, Set-HardDisk, New-VM, and New-HardDisk.
vSAN File Service Snapshot Management
If you use VSAN, you will probably know that you can use it as a file-sharing platform on top of running VMs. VSAN File Service lets you create file shares of various protocols using the vSAN datastore capacity of your cluster. Now, the cool thing is that you can create up to 32 snapshots of VSAN File Shares to provide a point-in-time image of it.
- New-VsanFileShareSnapshot
- Get-VsanFileShareSnapshot
- Remove-VsanFileShareSnapshot
Other enhancements
We only scratched the surface of the changes in PowerCLI 12.x here but here are a few other significant changes that are worth mentioning:
- Set CPU/Memory and Hot add/Remove config
- Managing VMware Cloud on AWS Outpost which was announced during VMworld 2021
- Support for Site Recovery Manager 8. Check out our series on the topic
- manage certificates on vCenter Server and ESXi
- Support for cross-vCenter operations
- vSAN file service Snapshot Management
- Tanzu and Cloud-Native Storage management capabilities
Wrap up
After so many years of having PowerCLI around since the early days of vSphere and probably helping every single VI admin at some point in the career, it is great to see that the product is still being maintained and improved. While the general consensus is that virtualization has become commodity like hardware many years ago, PowerCLI manages to find its way into all areas of the SDDC regardless of the trends. What used to be the “VMware hypervisor” CLI tools can now interact with cloud platforms, Kubernetes clusters and software-defined networking.
Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.