06 March 2020

Install PowerShell 7 with PowerShell Silently

Yesterday PowerShell 7 became GA, this means that I want to upgrade to this version the fastest way possible.
There's only one way to do this:
Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell-7.0.3-win-x64.msi" -OutFile "$env:TEMP\PowerShell-7.0.3-win-x64.msi"

$msifile = "$env:TEMP\PowerShell-7.0.0-win-x64.msi"
$arguments = @(
          "/i"
          "`"$msiFile`""
          "/passive"
)
Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList $arguments
Or the preview version:

Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.1.0-preview.6/PowerShell-7.1.0-preview.6-win-x64.msi" -OutFile "$env:TEMP\PowerShell-7.1.0-preview.6-win-x64.msi"
$msifile = "$env:TEMP\PowerShell-7.1.0-preview.6-win-x64.msi"
$arguments = @( "/i" "`"$msiFile`"" "/passive" ) Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList $arguments
Keep in mind that with PowerShell 7 the ISE is no longer available, and you need to shift to VisualStudio Code.
https://code.visualstudio.com/

Or with this oneliner:
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

No comments:

Post a Comment