Installing PowerShell Core using Windows PowerShell


This can sound silly but PowerShell Core can be installed using Windows PowerShell.

There is plenty of variations out there, shortest one liner what I have seen is this:

iex "& { $(irm } -UseMSI"

but still I made own variation of installation for WIndows 10

$coreVer = 'v6.2.0'

$corePackage = "PowerShell-$($coreVer.Substring(1))-win-x64.msi"

$coreUrl = "$coreVer/$corePackage"

$path = "C:\PowerShellCore$coreVer"

$file = "$path\$corePackage"

if(!(Test-Path $path)) {[void](New-Item $path -Type Directory -force)}

$request = Invoke-WebRequest -uri $coreUrl -OutFile $file

$arguments = '/i', "$file", '/qb-!'

Start-Process 'msiexec.exe' -ArgumentList $arguments -NoNewWindow -Wait

To test if installation was succeeded, open start menu and type “pwsh”.

Of course you can test installation with Windows PowerShell, on console run:

Start-Process 'C:\Program Files\PowerShell\6\pwsh.exe' -Wait -PassThru

Run $PSVersionTable on PowerShell Core console

Output should be similar


Thanks for reading