When PowerCLI was converted to modules, it introduced the ability to pick and choose which modules are loaded. Taking it a step further, it also allowed users to specify which versions of those modules are loaded. Historically, PowerCLI was released as one large lsquo;bundlersquo; of modules, and was not a great release practice. This meant that even though most modules were not touched, we were still required to go through our release processes to get them out the door. This is not scalable when trying to get features to you more frequently.
With modules in the Powershell Gallery, we can now release individual modules asynchronously from other modules. The first release to really take advantage of that is PowerCLI 6.5.2. For those whom have already updated their VMware.PowerCLI module from the Microsoft PowerShell Gallery, you noticed there were only 3 modules which were updated and needed to be downloaded.
The Better Way
In prior releases, we could use the lsquo;Get-PowerCLIVersionrsquo; cmdlet and receive a high-level look at the overall PowerCLI version which was installed. Previously, our versioning scheme was not supported in PowerShell, so it took a cmdlet to print the version out (Example: VMware PowerCLI 6.5 R1). That is gone now. Wersquo;ve made the change to semantic versioning in 6.5.1. This means there will be no more R1, R2, or R3 releases!
Starting with PowerCLI 6.5.2, the process to get module versions has changed. Running the lsquo;Get-PowerCLIVersionrsquo; cmdlet now results in a warning message indicating that it is deprecated and to use the lsquo;Get-Modulersquo; cmdlet instead.
There are a couple ways to use the lsquo;Get-Modulersquo; cmdlet to help us determine our versioning. The reason for that is because the lsquo;Get-Modulersquo; cmdlet only shows the modules which have been imported.
The first way is to get the overall PowerCLI version, which is dependent on the lsquo;VMware.PowerCLIrsquo; module. We can determine the version by first importing the module (if itrsquo;s not already imported) and then running the following command:
Get-Module -Name VMware.PowerCLI | Select-Object -Property Name,Version
From the above example, we can see that wersquo;re using PowerCLI version 6.5.2.
Another way is to just reference the modules which have been loaded automatically. I have an example where we connect to our vCenter Server and then run the following command to find the versions of all the PowerCLI modules which are in-use:
Get-Module -Name VMware.* | Select-Object -Property Name,Version
From the above example, we see that wersquo;re only using a single PowerCLI module and it happens to be versioned at 6.5.2.
Running a couple additional, random, commands, we re-run the above command and see therersquo;s now a bit more of a mix amongst our loaded modules.
The new method to obtain what version of PowerCLI you’re using is through the ‘Get-Module’ cmdlet. This update was made for many reasons. This new method takes advantage of how our the PowerCLI modules can be loaded independently of each other on an as needed basis. It also takes advantage of how the PowerCLI module releases can now be done asynchronously from each other. Lastly, since we’ve changed the PowerCLI versioning over to align with the standard PowerShell versioning, therersquo;s no need for a custom cmdlet anymore!
If you’re using ‘Get-PowerCLIVersion’ in your scripts or modules, make sure you’re aware of this and update your resources to reflect this change!
The post What PowerCLI Version Am I On Anyways? appeared first on VMware PowerCLI Blog.