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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This I think actually also needs the
Receive updates for other Microsoft products when you update Windowssetting to be on which I've previously done manually but I am lead to believe is done viaI reckon adding these below regkeys upfront (that the msi installer uses) would also ensure the installation goes as required