Comparing commands between PowerShell versions
In the article Decoding PowerShell build numbers, I stated the need to have some form of reference to what the various PowerShell build numbers means:
As stated in that article, due to the new and fast moving pace Microsoft have gotten into, we will see more frequent updates to PowerShell than before. Version number is one element, another one which is not easy to keep track of as a regular PowerShell user is what commands are new or changed. For example, parameters might be added or removed from existing cmdlets.
At the time of this writing, a new technical preview of Windows Server 2016 has just been released. But how can you know what is changed with regards to PowerShell commands?
There are some code snippets available to compare changes between versions. For example, Shay Levy’s script listed in this article. Since the need to perform this task will occur more and more often going forward, I decided to turn this into a reusable function. The function is named Compare-PSVersionCommand and is available in the module PSVersionCompare. You can either get it directly from GitHub, or use PowerShellGet to install it from the PowerShell Gallery: Install-Module -Name PSVersionCompare
In the initial version, Compare-PSVersionCommand have two parameter sets which makes it possible to compare based on either XML-files pre-gathered from systems, or data gathered directly via PowerShell remoting:
|
|
Here is an example which shows the differences in the native PowerShell modules between Windows Server 2016 Technical Preview 4 and Technical Preview 5:
Showing changes for all commands in all modules is impractical in an article like this, so a .txt file containing all changes is available here.
Same information for Windows Server 2016 Nano TP4->TP5 (TXT-file), using PowerShell remoting as input:
The XML files specified are generated by running the following on systems running the versions you want to compare:
|
|
If you run Get-PSVersionCommand without -Export, you will get all commands from system wide modules returned.
As you might know, there is a new $PSEdition variable (also exists in $PSVersionTable.PSEdition) introduced in the Windows Server 2016 Technical Previews. This is intended to distinguish PowerShell Core (used in Nano Server) from “regular PowerShell” called PowerShell Desktop. If -Path is not specified to Get-PSVersionCommand -Export, the default naming convention for the generated XML-file is “OS Caption_PSVersion_PSEdition.xml” (for example Microsoft Windows Server 2016 Datacenter Technical Preview 5_5.1.14284.1000_Core.xml).
When creating reference XML-files for server operating systems, I like to make sure that all Remote Server Administration Tools (RSAT) is installed on the reference computers in order to have all modules available for comparison. This can be accomplished like this:
|
|
There are a lot more features planned for this module, so check out the Git repository for the latest status (or run Update-Module -Name PSVersionCompare if you already installed it using PowerShellGet). Some of the planned features:
- A Name parameter for specifying what command to compare. If not specified, all commands will be compared.
- Options for output- formats, such as CSV, JSON, and HTML. Default output format is meant for interactive usage, not to export.
- An Online parameter for retrieving the XML files for the specified PS Versions from an online location. Defaults to the PSCommandData folder in the Git repository.
Although using PowerShell remoting for ad-hoc checking between two systems might be the most common scenario for using Compare-PSVersionCommand, the use of XML files should not be underestimated. If the community contributes with files to the PSCommandData folder in the Git-repository, over time we can gather a lot of information about commands in the different PowerShell versions making it easy to do comparisons without access to a system running a specific version.
Share on: