Update Powershell through command line

command linepowershellpowershell-5.0

I want to update a machine's Powershell version. Can this be done through the command line?

My present need is to update from PS 4 to PS 5 on a Windows server 2012R2.

I guess there is no catch-all solution for all Windows versions and all PS versions mixed with caveats like PS4 requiring Dotnet4.5 so let's keep the question as simple as possible, like the first two sentences above.

Best Answer

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

And then run the MSI with your parameters.

After this you need to update the modules.

Reference:

https://www.thomasmaurer.ch/2019/03/how-to-install-and-update-powershell-6/

https://www.thomasmaurer.ch/2019/02/update-powershellget-and-packagemanagement/

Related Question