How to Walk Through a PowerShell 7 Upgrade

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

PowerShell 7 is the newest version of PowerShell. Learn how to upgrade your environment from PowerShell 6.x to 7, and take advantage of new features like cross-platform scripting by learning about Windows Azure Pack as an alternative deployment option for IT Pros who deploy on-premises solutions.

The “update powershell 7” is a command-line tool that allows users to update their PowerShell version. The upgrade process can be tricky for beginners, so this guide will walk you through the process step by step.

How to Walk Through a PowerShell 7 Upgrade

Are you prepared to update to PowerShell 7 and take advantage of all of the new features? If that’s the case, this essay is for you.

The goal of PowerShell 6 was to offer a basic version of the scripting language on all platforms (PowerShell Core). We’re now seeking for all platforms to be equivalent in the PowerShell they can give with PowerShell 7 (which is the most recent PowerShell version as of this writing) (both Windows PowerShell and PowerShell Core).

In this post, you’ll learn how to manually upgrade PowerShell 7, as well as how to automate the update process in the future using GPO and PowerShell Remoting.

The current version of PowerShell 7 is Preview 3 as of this writing. This version will be covered by the majority of the references in this page.

How to Update a Machine’s PowerShell Version

The installation of PowerShell Core 7 is identical to that of PowerShell Core 6.0. Let’s have a look at a couple alternative approaches to getting PowerShell 7 installed on a single PC.

Before we go any further, there are a few criteria that must be met before PowerShell version 7 can be installed. You’ll see that these prerequisites are identical to those for PowerShell version 6.

  • It is necessary to install the Universal C Runtime.
  • If you’re using Windows 7 or Windows Server 2008R2, you’ll need Windows Management Framework (WMF) 4.0 or newer. WMF is no longer necessary in later versions of Windows, such as Windows 8.1, Windows 10, and Windows Server 2016.

Manually installing PowerShell 7

To begin, get PowerShell 7. To do so, go to the PowerShell GitHub Releases page and look for the version you wish to install. We’ll be using PowerShell 7.0.0 preview 3 for this tutorial. Scroll down to download and execute the PowerShell-7.0.0-preview.3-win-x86.msi MSI package for Windows.

Welcome screen for PowerShell 7 installationWelcome screen for PowerShell 7 installation

The wizard will ask you a few basic questions, such as where you want to install PowerShell. Use distinct installation directories if you want to run various versions of PowerShell at the same time.

If you wish to add PowerShell to the PATH environment variable, the wizard will ask you. By adding the PowerShell installation folder to the PATH environment variable, you may run PowerShell from any terminal, even another version of PowerShell or cmd.exe.

Register PowerShell with the Windows Event Logging Manifest is another approach. This option, when enabled, makes use of the comprehensive logging that comes with this version of PowerShell.

It then asks whether you want to activate PowerShell Remoting right now, which may assist with any remote job.

Finally, you’ll be asked whether you want to enable Explorer’s ‘Open Here’ context menus. When exploring in Windows Explorer, you may right-click on any folder and launch a PowerShell window inside that working directory.

Although the final two are entirely optional and up to you, I strongly advise you to enable the first two, as follows:

Choosing defaults during the installation of PowerShell 7Choosing defaults during the installation of PowerShell 7

After you’ve answered all of their questions, click Next to begin the installation.

PowerShell 7 is launched.

You may start PowerShell 7 by entering pwsh-preview in any command line terminal once it has been installed.

Once PowerShell version 7 is no longer in the “preview” phase, you won’t be able to use this command name. You’ll be able to use pwsh to start PowerShell 7 once it’s out of preview.

Using PowerShell to install PowerShell 7

Steve Lee, the Microsoft PowerShell project lead, tweeted a simple approach to install PowerShell 7 using the Invoke-RestMethod cmdlet in PowerShell. This code sample utilizes the command to search the PowerShell GitHub repository for an installation script, which then downloads and installs PowerShell 7 in one line.

The syntax for doing so is listed below. Run the one-liner below in a Windows PowerShell console.

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

The PowerShell Invoke-Expression cmdlet (iex in the one-liner) accepts a string and runs it as PowerShell code in this code snippet. The Invoke-RestMethod cmdlet (irm in the one-liner) is used to download the script that Steve has created. Before performing this command, I strongly advise you to visit the URL and examine the code for yourself!

The snippet then instructs the script to acquire and install the newest MSI using the UseMSI and Preview arguments.

The Quiet argument may be used to execute this script fully silently and unattended. The Preview parameter still refers to PowerShell 7 Preview 3 as of this writing.

Using a Module to Install PowerShell 7

Another option for installing PowerShell 7 is to use Jeff Hicks’ PSReleaseTools PowerShell module. Like Steve’s one-liner, this module keeps your PowerShell version up to date.

You may download the module with Install-Module and install PowerShell 7 preview using the Install-PSPreview command that comes with the PSRelaseTools module with only two lines of PowerShell.

PS51> Install-Module -name PSReleaseTools -Force PS51> Install-PSPreview -mode Quiet

PowerShell 7 Deployment Across an Organization

When it comes to implementing PowerShell 7 at scale, you have a few alternatives. Let’s take a look at two typical approaches.

Using a GPO to deploy PowerShell 7

PowerShell is simple to install through GPO since it integrates well with other Microsoft technologies and is bundled as an MSI. There are a few things to keep in mind when using GPO to deploy this.

Use a GPO that is computer-based.

To begin, be certain you’re using a computer-based policy rather than a user-based policy. More information on the differences between these two policies may be found here. On servers, users are often not interactively logging in, which initiates a deployment.

If you’re deploying PowerShell 7 to a large number of servers, you’ll want it to happen independent of user input.

Set up a File Sharing Network

Also, ensure that the network share on which the PowerShell 7 MSI is installed has the right permissions configured to enable access to all servers in your environment. More information about creating file sharing may be found here, albeit it is outside the scope of this article.

Create a GPO.

Then, using the methods below, you’ll construct your GPO:

  • Install the MSI to a file share that your machines can access.
  • Within the Group Policy Management Console, create a beginning GPO. You may learn more about GPOs for beginners here.
  • Once the GPO is created, open it up and navigate to Computer Configuration –> Software Settings.
  • Right-click Software Installation then select New –> Package.
  • Add the whole UNC path to the MSI in the dialog box. For example, if folder is a file share on server.namef, the path would be server.namef. namefolderpowershell-7.msi
  • Click Open –> Assigned –> OK.

The GPO must be attached to the required OU (s)

Once created, The GPO must be attached to the required OU (s). Check back in a couple of hours and the deployment should be mostly complete.

Check the Status of the GPO Installation

Check out this small script below to produce a report with the Group Policy object deployed to machines in a given OU if you prefer a more hands-on approach to reviewing your Group Policy deployment.

Change the OU distinguished name to your OU (OU=Domain Controllers,DC=mylab,DC=local).

With the PowerShell ActiveDirectory module loaded, you may execute this on a domain controller or a domain-joined PC.

Get $computers -ADComputer -Filter * -ADComputer -Filter * -ADComputer ForEach ($computer in $computers) -SearchBase ‘OU=Domain Controllers, DC=mylab, DC=local’ -Computer Get-GPResultantSetOfPolicy c:temp$computer.html -ReportType HTML -Path $computer

The command below will come in helpful if you want to spot check certain servers. It connects to a remote machine ($computer) and uses $PSVersionTable to verify the version of PowerShell installed on that computer. PSVersion.

PS> Invoke-Command -Computername $computer -Scriptblock {$PSVersionTable.psversion}

Finally, if you discover any PCs that do not have group policy applied, execute the following command to force group policy refresh on the target computer:

Using PowerShell Remoting to deploy PowerShell 7

PowerShell is another wonderful approach to deploy PowerShell to distant workstations. Although it may seem a bit meta, PowerShell is a powerful enough scripting language to help with the replacement’s installation.

Before you begin, make sure PowerShell remoting is turned on and that the relevant permissions for running remote commands throughout your environment have been set up. A guide to enabling PSRemoting through GPO may be found here.

You’ll need to “wrap” that command in a scriptblock and instruct the Invoke-Command command to run it across one or more remote computers, because you already know the one-liner to install PowerShell.

The example below shows cycling over a list of machines stored in the $computers array and then executing the install-powershell.ps1 script on each one.

$creds = $(Get-Credential) ForEach ($computer in $computers) { Invoke-Command -ComputerName $computer -Credential $creds {iex “& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI -Preview -Quiet”} }

Summary

There are several reasons to maintain your PowerShell version current, if not in your production environment, at the very least on your personal system. You’ll be able to access the most up-to-date features, benefit from speed improvements, and even assure that your older code won’t break in subsequent versions.

As you can see, there are several options for downloading and installing updated PowerShell versions. Choose the solution that works best in your situation and keep PowerShelling!

Additional Reading

PowerShell 7 is the latest version of the popular scripting language. In order to upgrade your system, you need to download powershell 7 and install it on your machine.

Related Tags

  • update powershell 7 command line
  • upgrade powershell 5.1 to 7
  • powershell 7.0 1 win-x64 msi download
  • powershell update command
  • powershell 7 ise

Table of Content