PowerShell 6.0 Release Tools

As you should be aware, the next version of PowerShell is open source and cross-platform. You will be able to run PowerShell v6 on Windows, a Mac and select Linux distributions. All of the code is currently in alpha and hosted on the PowerShell GitHub repository. This is also where you can download new builds to install and test. I’ll admit I’m a little behind the curve and part of that is because I don’t often check if there is a new release. So I built a PowerShell module that will do that for me, and even download new installation packages. The best part, is that this should work cross-platform.

My module, called PSReleaseTools, currently has 3 commands.

  • Get-PSReleaseSummary
  • Get-PSReleaseAsset
  • Save-PSRelease

All of the functions take advantage of the GitHub API which in combination with either Invoke-RestMethod or Invoke-WebRequest, allow you to programmatically interact with GitHub.

The first command queries the PowerShell repository release page and constructs a text summary.

image

I put the release name and date right at the top so you can quickly check if you need to download something new. In GitHub, each release file is referred to as an asset. The Get-PSReleaseAsset command will query GitHub about each file and write a custom object to the pipeline.

image

By default it will display assets for all platforms, but I added a -Family parameter if you want to limit yourself to a single entry like MacOS.

image

Of course, you will want to download these files which is the job of the last command. By default the command will save all files to the current directory unless you specify a different path. You can limit the selection to a specific platform via the -Name parameter which uses a validation set.

image

You can select multiple names. If you select only Windows names then there is a dynamic parameter called Format where you can select ZIP or MSI. And the command supports -WhatIf.

image

I also realized you might run Get-PSReleaseAsset, perhaps to examine details before downloading. Since you have those objects, why not be able to pipe them to the save command? The command has Filename, Size and URL parameters which accept pipeline input by property name so that you can pipe like this:

image

By the way, I’m using the file size to test if the file downloaded completely. I know there are hashes in the release page but I didn’t feel like trying to parse them out and I can’t find them anywhere else. Using Size seems to work just fine.

Now I have everything I need to keep on top of the latest builds of PowerShell v6. I also have reports that this works on non-Windows systems running the v6 alpha bits. You can find the module on GitHub at https://github.com/jdhitsolutions/PSReleaseTools. Try it out everywhere and let me know how it goes. Please use Issue tracking on GitHub. Once I get a bit more feedback I’ll package this up and publish to the PSGallery.

Leave a Reply

Your email address will not be published. Required fields are marked *