Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Last active September 26, 2023 05:52
Show Gist options
  • Save kilasuit/35456edca09dc825fa8510a6c89fb91d to your computer and use it in GitHub Desktop.
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment