Script To Download the Current Version of PowerShell

One of the annoying things about well, any software is checking to see if you have the currrent version. This is a thing with PowerShell, and because the PowerShell team in its finite wisdom has decided to not just have a "latest stable/lts/preview" url, we have to figure this out manually. It's not too bad though, fortunately, the PowerShell team gives us…

https://bynkiidotcom.wordpress.com/2025/11/11/script-to-download-the-current-version-of-powershell/

#PowershellMac
#powershellmacos
#powershell

Script To Download the Current Version of PowerShell

One of the annoying things about well, any software is checking to see if you have the currrent version. This is a thing with PowerShell, and because the PowerShell team in its finite wisdom has de…

Bynkiidotcom

Script To Download the Current Version of PowerShell

One of the annoying things about well, any software is checking to see if you have the currrent version. This is a thing with PowerShell, and because the PowerShell team in its finite wisdom has decided to not just have a “latest stable/lts/preview” url, we have to figure this out manually.

It’s not too bad though, fortunately, the PowerShell team gives us a good way to check and a bit of simple comparison to help us determine if we have the newest version. The basic flow is “get the current installed version of PowerShell, then check to see if the current version on github is newer. If it is, download that.”

Now, there’s a couple caveats: the installed version is based on what you’re running the script in. So if you’re going between say stable and preview, if you run the version checker in stable, that will give the version for stable. You’ll have to run it in preview for that, and do your own version comparison. I’m just doing this based on stable.

To see what the current installed version of PowerShell is, we run $PSVersionTable.psversion.ToString() which gives us a nice neat value, so for stable on my machine, I get: 7.5.4

We then want to see what the current stable downloadable version is. Fortunately, the PowerShell team does us a solid by making that available from a stable URL as JSON data. For stable, the URL is: https://aka.ms/pwsh-buildinfo-stable. To check for lts or preview, change -stable to -lts or -preview. If we hit that URL, we get a json file with the following

{ "BaseUrl": "https://powershellinfraartifacts-gkhedzdeaghdezhr.z01.azurefd.net/install", "ReleaseTag": "v7.5.4", "ReleaseDate": "2025-10-20T19:26:23Z", "BlobName": "v7-5-4"}

The ReleaseTag is the thing of the most interest to us. When it comes to downloading, while not giving us a “latest” URL, the PowerShell team does give us a fairly consistent URL pattern. For example, for the installer package for the Apple Silicon macOS version, the URL is: https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/powershell-7.5.4-osx-arm64.pkg, so we can see where we can use the ReleaseTag directly in the URL in between download/ and /powershell-, and then if we yank the leading v off the ReleaseTag, we can use that in the actual package name. Consistency is really handy. The script itself then is:

  • Get the installed version
  • Get the current github version
  • if the current github version is newer/greater than the installed version, download that package file to /tmp
  • We use Invoke-RestMethod as our “curl” command, since in this case, it gives us the JSON data in a usable way sans any custom parsing. From there, install it via whatever method you wish. Obviously, the script is a PowerShell script, duh. So the script:

    #get the installed (stable) version$installedPSVersion = $PSVersionTable.psversion.ToString()#get the JSON data from github$PSLatestStableVersionInfo = Invoke-RestMethod -Uri "https://aka.ms/pwsh-buildinfo-stable" -Method Get#get the releasetag$PSLatestStableReleaseTag= $PSLatestStableVersionInfo.ReleaseTag#build the version sans the leading v$PSLatestStableVersion = $PSLatestStableReleaseTag.Substring(1)#test to see if github is newerif ($PSLatestStableVersion -gt $testVersion) { #github version is newer, build the download URL $macOSPowerShellASPKGDownloadURL = "https://github.com/PowerShell/PowerShell/releases/download/$PSLatestStableReleaseTag/powershell-$PSLatestStableVersion-osx-arm64.pkg" #build our download filename $macOSPowerShellASPKG = "powershell-$PSLatestStableVersion-osx-arm64.pkg" #now we download the file to /tmp Invoke-RestMethod -Uri $macOSPowerShellASPKGDownloadURL -Method Get -OutFile "/tmp/$macOSPowerShellASPKG"}

    And that’s it. Run this, and when it’s finished, if the github version is newer, you’ll have that package file in /tmp (as $deity intended), ready to go for whatever your next steps are.

    #automation #DownloadLatestPowerShellAutomatically #macPowershell #PowerShell #powershellFun #PowershellMac

    PowerShell script signer is done!

    Well, it's a 1.0.1, there’s a few things I want to add, but it's not bad at the moment. It's on the PowerShell Gallery at: https://www.powershellgallery.com/packages/Set-PowerShellScriptSig/1.0.1 and the github link is at: https://github.com/johncwelch/pwshsigner

    the readme on the github repo has the small number of future improvements I have planned, but for now, it's a solid MVP.

    #PowershellMac
    #powershellmacos
    #powershell

    Set-PowerShellScriptSig 1.0.1

    A module to make signing scripts easier

    Get-MacInfo 2.0.1

    A macOS version of the Get-ComputerInfo module

    My new PowerShell module, GetChooseFileName is now up on the PowerShell Gallery:

    https://www.powershellgallery.com/packages/Get-ChooseFileName

    #powershell
    #powershellmac
    #powershellmacos

    Get-ChooseFileName 1.0

    A module providing a PowerShell interface to the AppleScript "Choose File Name" UI Primitive

    Get-ChooseFileName is basically done, getting approval before releasing up to the PowerShell gallery: https://github.com/johncwelch/Get-PSChooseFileName

    #powershell
    #powershellmac
    #powershellmacos

    GitHub - johncwelch/Get-PSChooseFileName: A bridge to AppleScript's Choose File Name command

    A bridge to AppleScript's Choose File Name command - johncwelch/Get-PSChooseFileName

    GitHub
    GitHub - johncwelch/Get-PSChooseFileName: A bridge to AppleScript's Choose File Name command

    A bridge to AppleScript's Choose File Name command - johncwelch/Get-PSChooseFileName

    GitHub

    Getting Warranty Info on your Mac with PowerShell

    This was a feature someone asked for with Get-MacInfo. Here's the basics, the script is on the github site, and VERY REAL WARNINGS:

    This is incredibly fragile, as it relies on a directory, com.apple.NewDeviceOutreach, being in ~/Library/Application Support/ for the user running the script. I'm not even going to try to play "peekaboo in other user homedirs" with a…

    https://bynkiidotcom.wordpress.com/2025/02/04/getting-warranty-info-on-your-mac-with-powershell/

    #powershell
    #powershellmac
    #powershellmacos

    Getting Warranty Info on your Mac with PowerShell

    This was a feature someone asked for with Get-MacInfo, and now that I have it, I can work on integrating it. Here’s the basics, the script is on the github site, and VERY REAL WARNINGS: This …

    Bynkiidotcom

    Get-ChooseFile and Get-ChooseFolder posted at the PowerShell Gallery!

    Both modules are finally published so they can be installed the “right” way!

    Get-ChooseFile

    Get-ChooseFolder

    Get-Help is your friend and there’s documentation on their respective Github repo pages, available via the “Project Site” links for the respective projects

    #PowerShell #PowerShellGallery #PowershellMac #PowerShellModules #powershellApplescriptBridge

    Get-ChooseFile 1.0

    A module providing a PowerShell interface to the AppleScript "Choose File" UI Primitive

    One advantage of moving to JSON for system_profiler output as opposed to line numbers is that I can get rid of a LOT of duplication.

    Directly addressing elements doesn’t suck.

    #powershell
    #powershellmac