Windows Server

How to install and update PowerShell version 7 on Windows and Linux

How to install and update PowerShell version 7 on Windows and Linux

On March 4th, 2020, Microsoft announced the Generally Available (GA) release of PowerShell 7.0. PowerShell 7 is the latest major update to PowerShell, a cross-platform (Windows, Linux, and macOS) automation tool and configuration framework optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. PowerShell includes a command-line shell, object-oriented scripting language, and a set of tools for executing scripts/cmdlets and managing modules.

Operating systems supported PowerShell 7: PowerShell support ARM32 and ARM64 flavors of Debian and Ubuntu, as well as ARM64 Alpine Linux many others as listed below.
– Windows 10
– Windows Server 2012, 2012 R2, 2016, and 2019
– macOS 10.13+
– Red Hat Enterprise Linux (RHEL) / CentOS 7+
– Fedora 29+
– Debian 9+
– Ubuntu 16.04+
– openSUSE 15+
– Alpine Linux 3.8+

Note: Although not officially supported, the community has also provided packages for Arch and Kali Linux.

Microsoft products already in support of PowerShell 7: Any module that is already supported by PowerShell Core 6.x is also supported in PowerShell 7, including:
– Azure PowerShell (Az.*)
– Active Directory
Also, many of the modules in Windows 10 and Windows Server as well. use the following commands to get the available list

Get-Module -ListAvailable

With this guide, you will learn how to upgrade to PowerShell v7 manually
– First, determine the current version of PowerShell that you are using, see the following link for more details
https://techdirectarchive.com/2020/02/26/how-to-determine-windows-powershell-version-and-to-see-if-winrm-is-running-via-test-wsman/

As we can see, we are currently on version 5.1 as shown below

Windows: One-liner to install (update) PowerShell 7 on Windows 10
– Launch PowerShell with Administrative privilege and run the command below.

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

In few seconds or minutes, this will prompt the PowerShell installer Window as shown below
– Click on Next

Select the destination folder you would like PowerShell to be installed to.
– I will leave it as default as I am ok with it.

Under Optional Actions,
– Enable the follow as shown below. The last option i did not enable is up to you if you would like to enable it.

The wizard will also ask you to register PowerShell to the PATH environment variable. Adding the PowerShell installation folder to the PATH environment variable allows you to call PowerShell from any other terminal such as a different version of PowerShell or even cmd.exe as we will see at the end of this installation.

Also enable PowerShell Remoting from the this Window and this can help with all remote tasks.

Note: Add 'Open Here' context menus to Explorer. This option enables you to right-click on any folder when browsing in the Windows Explorer and open a PowerShell window within that working directory.

Finally, click on done to install or update PowerShell 7 to your device

This will continue the install process as shown below

When you are done, click on finish

Because I selected the option to launch PowerShell, it automatically fired up PowerShell and as we can see, we are currently running PowerShell version 7.

When this step is completed, ensure to update the PowerShellGet and Package Management. For more information, see https://techdirectarchive.com/2020/05/22/powershell-how-to-update-powershellget-and-package-management/

Note: You can also download the MSI from here and to install PowerShell 7 silently, use the following command below.

msiexec.exe /package PowerShell-7.0.1-win-x64.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1

Linux: One-liner script to install (update) PowerShell 7 on Linux
– Open your Linux terminal and run the command below to update to PowerShell 7

pwsh

As we can see, we currently do not have PowerShell running on this Ubuntu server. To view PowerShell.
At this moment of writing this article, PowerShell is currently not support on Ubuntu 20.04.

Therefore, feel free to try out this one-liner installation with other versions of Ubuntu.

wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh; rm install-powershell.sh

Enter your password to continue. When this is done, this process will complete successfully.

For other installation methods for linux, please visit this link for more information https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7

When this step is completed, ensure to update the PowerShellGet and Package Management. For more information, see https://techdirectarchive.com/2020/05/22/powershell-how-to-update-powershellget-and-package-management/

Note: PowerShell 7.1 is currently being developed.

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x