PowerShell 7 and 7.1

Released on March 4th, 2020 (PowerShell 7) and November 11th, 2020 (PowerShell 7.1)

PowerShell 7 is the newest version of Microsoft’s incredibly powerful, cross-platform (Windows, macOS, and Linux), scripting language.

The new version of PowerShell installs and runs side-by-side with Windows PowerShell (version 5.1 and lower, PowerShell 6 requires additional steps to work side-by-side with 7 and will be replaced by 7 on install). PowerShell 7 offers Improved compatibility with existing Windows PowerShell modules as well as several New language features.

Important Product Lifetime information PowerShell 7.0 is an LTS (Long Term Support) release and will be supported until December of 2022. Version 7.1 will be supported until 3 months after the release of .NET 6 (Nov 2021), which will be February 2022. While this isn’t a significant difference, it is something that you should be aware of. Also, PowerShell will provide automatic update information depending on what version you are using. If you have the LTS version, it will let you know when the next LTS version is released, for a minor version it will let you know when the next minor update is released (for example 7.1 to 7.2).

Is it worth installing?

It depends. Are you able to install it on your machine? and Do you want to use the latest features, like: ternary expressions, null coalescing operators, a simplified error view, and more?

Can You Install it on Your Machine

PowerShell 7 has a wide range of compatible operating systems and architectures, with 7.1 offering even more compatibility.

In addition to the broad compatibility, there are several ways to install PowerShell 7.

Since this blog is focused on Windows, the easiest options are by using the .msi file, or using the Windows Store website/application (for 7.1+ only, see below for some additional information). Using the .zip installation offers more flexibility but requires a bit more work on your end.

Another option is to use a handy tool put together by the PowerShell team, which will download and run the setup wizard automatically (using the .msi).

Open PowerShell, then paste this command and press Enter:

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

Installing from the Microsoft Store (Benefits and Warnings)

PowerShell 7.1 is available in the Microsoft Store.

Benefits of the Microsoft Store package:

  • Automatic updates built right into Windows 10
  • Integrates with other software distribution mechanisms like Intune and SCCM

Limitations:

  • runs in an application sandbox that virtualizes access to some filesystem and registry locations
  • All registry changes under HKEY\_CURRENT\_USER are copied on write to a private, per-user, per-app location. Therefore, those values are not available to other applications.
  • System-level configuration settings stored in $PSHOME cannot be modified. This includes the WSMAN configuration. This prevents remote sessions from connecting to Store-based installs of PowerShell. User-level configurations and SSH remoting are supported.

Powershell-Windows-Store[1].png

For a full listing of installation options and instructions see:

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7

PowerShell 7 currently supports the following operating systems on x64, including:

  • Windows 8.1, and 10
  • Windows Server 2012, 2012 R2, 2016, and 2019
  • macOS 10.13+
  • Red Hat Enterprise Linux (RHEL) / CentOS 7
  • Fedora 30+
  • Debian 9 (including ARM32 and ARM64)
  • Ubuntu LTS 16.04+ (including ARM32 and ARM64)
  • Alpine Linux 3.8+ (ARM64)

PowerShell 7.1 is supported the following additional operating systems/architectures:

  • Windows 8.1/10 (including ARM64)
  • Windows Server Semi-Annual Channel (SAC)
  • Ubuntu 19.10 (via Snap package)
  • Debian 10
  • CentOS and RHEL 8
  • Alpine 3.11+ (including ARM64)

PowerShell 7.1 also has community support for:

  • Arch Linux
  • Raspbian Linux
  • Kali Linux

Do You Want to Use the Latest Features

PowerShell 7 introduces a number of new language features:

  • ternary operators
  • ForEach-Object -Parallel
  • Improved performance
  • SSH-based remoting
  • Cross-platform interoperability
  • Support for Docker containers
  • PowerShell 7 works side-by-side with Windows PowerShell letting you easily test and compare between editions before deployment. Migration is simple, quick, and safe.

Ternary Operator

Ternary Operators allow for extremely concise If-Else statements. So using a ternary statement:

a ? b : c

is the equivalent of:

if (a) {b} else {c}

ForEach-Object -Parallel

ForEach-Object -Parallel will easily leverage parallelization to execute tasks. This is a considerable improvement over the previous system for multi-threading in 5.1 which had significant overhead and, frankly, wasn’t worth using most of the time.

Pipeline chain operators: || and &&

Pipeline chain operators: || and && allow you to build logic directly into your pipeline by executing based on the outcome of the process before them. || is conditional OR, && is conditional AND.

Additional new features include:

  • Null conditional operators: ?? and ??=
  • A simplified and dynamic error view
  • Get-Error cmdlet for easier investigation of errors
  • A compatibility layer that enables users to import modules in an implicit Windows PowerShell session
  • Automatic new version notifications
  • The ability to invoke DSC resources directly from PowerShell 7 (experimental)

For a full listing (including detailed descriptions and examples) of new features see: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/what-s-new-in-powershell-70?view=powershell-7.1

PowerShell 7.1

PowerShell 7.1 primarily focused on community issues and making improvements and fixes to PowerShell, improving stability and performance.

However, PowerShell 7.1 includes PSReadLine 2.1.0, which includes Predictive IntelliSense, which seems to significantly enhance your tab completion. Predictive Intellisense enables you to see, edit, and execute full commands based on matching predictions from your history as well as additional domain specific plugins.

PSReadLine 2.1.0 can also be installed on PowerShell 5.1 or 7.0+ by running:

Install-Module PSReadLine -RequiredVersion 2.1.0

For more information about Predictive IntelliSense see the announcement in the PowerShell blog.

And for more information about starting on your automation journey, check out more articles on EnablingAutomation.com