Skip to content

kpd956/PSReleaseTools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSReleaseTools

PSGallery Version PSGallery Downloads

PSAvatar

This PowerShell module provides a set of commands for working with the latest releases from the PowerShell GitHub repository. The module contains commands to get summary information about the most current release as well as commands to download some or all of the release files.

These commands utilize the GitHub API which is subject to rate limits. It is recommended that you save results of commands like Get-PSReleaseAsset to a variable. If you encounter an error message for Invoke-RestMethod like "Server Error" then you have likely exceeded the API limit. You will need to wait a bit and try again.

Cross-Platform

This module should work cross-platform on both Windows PowerShell and PowerShell 7.x.

Notes

The module currently has 6 commands:

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, Get-PSReleaseSummary queries the PowerShell repository release page and constructs a text summary. You can also have the command write the report text as markdown.

get-psreleasesummary.png

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.

PS C:\> Get-PSReleaseAsset

FileName      : PowerShell-7.0.0-win-x64.msi
Family        : Windows
Format        : msi
SizeMB        : 87
Hash          : 876F4A64012A1FB024DCCEA696DB00C5CD1A37C8DC9DFA2431C58CDF9F82950B
Created       : 3/3/2020 10:55:37 PM
Updated       : 3/3/2020 10:55:39 PM
URL           : https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/PowerShell-7.0.0-win-x64.msi
DownloadCount : 46253
...

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.

PS C:\> Get-PSReleaseAsset -Family MacOS

FileName      : powershell-7.0.0-osx-x64.pkg
Family        : MacOS
Format        : pkg
SizeMB        : 55
Hash          : 80F75903E9F33B407A7F15C087A2C2B12A93DC153469E091D18048D01080085E
Created       : 3/4/2020 6:13:06 PM
Updated       : 3/4/2020 6:13:08 PM
URL           : https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/powershell-7.0.0-osx-x64.pkg
DownloadCount : 7995
...

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 -Family parameter which uses a validation set.

PS C:\> Save-PSReleaseAsset -Family Ubuntu -Path D:\PS\ -WhatIf
What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/powershell-lts_7.0.0-1.ubuntu.16.04_amd64.deb" on target "D:\PS\powershell-lts_7.0.0-1.ubuntu.16.04_amd64.deb".
What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/powershell-lts_7.0.0-1.ubuntu.18.04_amd64.deb" on target "D:\PS\powershell-lts_7.0.0-1.ubuntu.18.04_amd64.deb".
What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/powershell_7.0.0-1.ubuntu.16.04_amd64.deb" on target "D:\PS\powershell_7.0.0-1.ubuntu.16.04_amd64.deb".
What if: Performing the operation "Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/powershell_7.0.0-1.ubuntu.18.04_amd64.deb" on target "D:\PS\powershell_7.0.0-1.ubuntu.18.04_amd64.deb".

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

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?

PS C:\> Get-PSReleaseAsset -Family Debian -LTS | Save-PSReleaseAsset -Path D:\PS\ -Passthru


    Directory: D:\PS

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           3/11/2020 12:44 PM       61101934 powershell-lts_7.0.0-1.debian.10_amd64.deb
-a---           3/11/2020 12:44 PM       61101718 powershell-lts_7.0.0-1.debian.11_amd64.deb
-a---           3/11/2020 12:44 PM       61100218 powershell-lts_7.0.0-1.debian.9_amd64.deb

The current version of this module uses regular expression named captures to pull out the file name and corresponding SHA256 hashes. The save command then calls Get-FileHash to get the current hash and compares them.

Preview Builds

Starting in v0.8.0, command functions have a -Preview parameter which will get the latest preview build. Otherwise, the commands will use the latest stable release.

Installing a Build

On Windows, it is pretty easy to install a new build with a one-line command like this:

 Get-PSReleaseAsset -Family Windows -Only64Bit -Format msi | Save-PSReleaseAsset -Path d:\temp -Passthru | Invoke-Item

Or you can use one of two newer functions to install the latest 64bit release. You can specify the interaction level.

Install-PSPreview will download the latest 64 bit preview build for Windows and kick off the installation.

Install-PSPreview -mode passive

Install-PowerShell will do the same thing but for the latest stable release.

PS C:\> Install-PowerShell -mode quiet -EnableRemote -EnableContextMenu

The functionality of these commands could have been combined, but I decided to leave this as separate commands so there is no confusion about what you are installing.

Non-Windows platforms have existing installation tools that work great from the command-line. Plus, I don't have the resources to develop and test installation techniques for all of the non-Windows options. That is why install-related commands in this module are limited to Windows.

PowerShell Gallery

This module has been published to the PowerShell Gallery. You should be able to run these commands to find and install it.

Install-Module PSReleaseTools

On PowerShell you might need to run:

Install-Module PSReleaseTools [-scope currentuser]

Support

If you have suggestions or encounter problems, please post an issue in this GitHub repository.

Last Updated 2020-03-27 14:20:46Z UTC

About

A set of commands for working with PowerShell 7.x releases.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PowerShell 100.0%