Last active
April 4, 2025 03:26
-
-
Save kilasuit/35456edca09dc825fa8510a6c89fb91d to your computer and use it in GitHub Desktop.
Some functions out of my setup script for installing Pwsh & PwshPreview via Microsoft update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Install-PwshPreview { | |
$pwshRegPath = "HKLM:\SOFTWARE\Microsoft\PowerShellCore" | |
$previewPath = Join-Path -Path $pwshRegPath -ChildPath "InstalledVersions\39243d76-adaf-42b1-94fb-16ecf83237c8" | |
if (!(Test-Path -Path $previewPath)) { | |
$null = New-Item -Path $previewPath -ItemType Directory -Force | |
} | |
Set-ItemProperty -Path $pwshRegPath -Name UseMU -Value 1 -Type DWord | |
Set-ItemProperty -Path $previewPath -Name Install -Value 1 -Type DWord | |
} | |
function Install-Pwsh { | |
$pwshRegPath = "HKLM:\SOFTWARE\Microsoft\PowerShellCore" | |
$StablePath = Join-Path -Path $pwshRegPath -ChildPath "InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1" | |
if (!(Test-Path -Path $StablePath)) { | |
$null = New-Item -Path $StablePath -ItemType Directory -Force | |
} | |
Set-ItemProperty -Path $pwshRegPath -Name UseMU -Value 1 -Type DWord | |
Set-ItemProperty -Path $StablePath -Name Install -Value 1 -Type DWord | |
} | |
Install-PwshPreview | |
Install-Pwsh |
However due to a bug in the update manifest that I reported you can see that v7.4.3 is also being downloaded unnecessarily.
This I think actually also needs the Receive updates for other Microsoft products when you update Windows
setting to be on which I've previously done manually but I am lead to believe is done via
Set-ItemProperty 'HKLM:\Software\Microsoft\WindowsUpdate\UX\Settings' -Name AllowMUUpdateService -Type DWord -Value 1
I reckon adding these below regkeys upfront (that the msi installer uses) would also ensure the installation goes as required
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of 2025/04/04 03:00am UTC +1 - I know this works as a way to ask Microsoft Update to install PowerShell or PowerShell Preview for you (as I've used it before)
I think adding
Prior to checking for updates should force the current 7.4.7 LTS install via this mechanism & not the current 7.5.0 stable release