|
# This example Script gives you lots of different ways to install the following random matrix of PowerShell versions |
|
|
|
## It is **NOT** intended to be run as a script however will work |
|
## It is however intended as a reference for how to install different versions of PowerShell in different ways |
|
## to the Install-PowerShell.ps1 Readme file https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1-README.md |
|
|
|
# Daily |
|
# Stable |
|
# Preview |
|
# LTS |
|
# 7.4.0-preview.4 |
|
# 7.3.4 |
|
# 7.3.3 |
|
# 7.2.10 |
|
|
|
# |
|
|
|
# All versions will be side by side installed in C:\ (So needs to be run as admin) |
|
# However, you can change the destination folder by changing the -destination parameter as that you can install it anywhere you want instead |
|
# If you don't provide a destination it will install in current users local appdata folder (on Windows that is C:\Users\username\AppData\Local\) or will install in "~/.powershell" on Linux and macOS |
|
|
|
$destination = "-Destination 'C:\ps'" # Comment out this line to install in current users local appdata folder instead. |
|
# Eventually this line will be simplified by going back to the https://aka.ms/install-powershell.ps1 link instead but is waiting on this [PR](https://github.com/PowerShell/PowerShell/pull/19884/) to be merged |
|
$scriptURL = 'https://raw.githubusercontent.com/kilasuit/PowerShell/update-install-powershell-script/tools/install-powershell.ps1' |
|
$IEXScriptBlock_Part1 = "& {$(Invoke-RestMethod $scriptURL)}" |
|
|
|
# Daily |
|
$DailyScriptBlock = "$IEXScriptBlock_Part1 -daily $destination" |
|
Start-Job -Name Daily -ScriptBlock { Invoke-Expression $using:DailyScriptBlock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -daily -destination $Destination" |
|
# invoke-expression "& {$(Invoke-RestMethod https://raw.githubusercontent.com/kilasuit/PowerShell/update-install-powershell-script/tools/install-powershell.ps1)} -daily -destination 'C:\ps'" |
|
|
|
# Stable |
|
$StableScriptBlock = "$IEXScriptBlock_Part1 -Stable $destination" |
|
Start-Job -Name Daily -ScriptBlock { Invoke-Expression $using:StableScriptBlock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Stable -destination $Destination" |
|
# Invoke-Expression "& {$(Invoke-RestMethod https://raw.githubusercontent.com/kilasuit/PowerShell/update-install-powershell-script/tools/install-powershell.ps1)} -Stable -destination 'C:\ps'" |
|
|
|
# Preview |
|
$PreviewScriptBlock = "$IEXScriptBlock_Part1 -Preview $destination" |
|
Start-Job -Name Daily -ScriptBlock { Invoke-Expression $using:PreviewScriptBlock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Preview -destination $Destination" |
|
# Invoke-Expression "& {$(Invoke-RestMethod https://raw.githubusercontent.com/kilasuit/PowerShell/update-install-powershell-script/tools/install-powershell.ps1)} -Preview -destination 'C:\ps'" |
|
|
|
# LTS |
|
$ltsScriptBlock = "$IEXScriptBlock_Part1 -LTS $destination" |
|
Start-Job -Name LTS -ScriptBlock { Invoke-Expression $using:ltsScriptBlock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -LTS -destination $Destination" |
|
|
|
|
|
# 7.4.0-preview.4 |
|
$v740preview4ScriptBlock = "$IEXScriptBlock_Part1 -Version v7.4.0-preview.4 $destination" |
|
Start-Job -Name v740preview4 -ScriptBlock { Invoke-Expression $using:v740preview4ScriptBlock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Version v7.4.0-preview.4 -destination $Destination" |
|
|
|
# 7.3.4 |
|
$v734scriptblock = "$IEXScriptBlock_Part1 -Version v7.3.4 $destination" |
|
Start-Job -Name v734 -ScriptBlock { Invoke-Expression $using:v734scriptblock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Version v7.3.4 -destination $Destination" |
|
|
|
# 7.2.10 |
|
$v7210scriptblock = "$IEXScriptBlock_Part1 -Version v7.2.10 $destination" |
|
Start-Job -Name v7210 -ScriptBlock { Invoke-Expression $using:v7210scriptblock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Version v7.2.10 -destination $Destination" |
|
|
|
$v733scriptblock = "$IEXScriptBlock_Part1 -Version v7.3.3 $destination" |
|
Start-Job -Name v733 -ScriptBlock { Invoke-Expression $using:v733scriptblock} |
|
# Invoke-Expression "& {$(Invoke-RestMethod $scriptURL)} -Version v7.3.3 -destination $Destination" |
|
|
|
# Wait for all jobs to finish |
|
Get-Job | Wait-Job | Receive-Job | Remove-Job |