Skip to the main content.

ScriptRunner Blog

PowerShell 7: What are the pros and cons of switching from Windows PowerShell 5.1?

Table of content

Post Featured Image

Windows PowerShell 5.1 is usually preinstalled and the default – is it worth switching to PowerShell 7, or will it lead to more work and problems?

In 2018, PowerShell Core was released in version 6, bringing a breath of fresh air to the PowerShell world: platform independence! Thanks to .NET Core, PowerShell now runs not only on Windows, but also on MacOS and Linux.

The catch? Windows PowerShell 5.1 is still the standard in many organizations because it comes preinstalled. Support for PowerShell 5.1 is tied to the version of Windows you are running. This means that PowerShell 5.1 will be around for a while, but no new features will be added. As a result, many administrators are wondering whether it is even necessary to upgrade to PowerShell 7 because of the increased administrative overhead (installing and maintaining PowerShell 7 on clients and servers) or compatibility issues with existing scripts.


Installing PowerShell 7

The latest version of PowerShell is easy to install on Windows, Linux, and MacOS. A consolation for the lack of pre-installation of the latest version of PowerShell on Windows systems: Since version 7.2 (Windows version 1709 and later), PowerShell can be updated using WSUS, which greatly reduces the administrative burden on administrators. The following are the commands to install on each operating system:


Windows with winget:

winget install --id Microsoft.Powershell --source winget


MacOS with homebrew:

brew install --cask powershell


Debian Linux:


# Prerequisites

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages
sudo apt-get install -y wget

# Get the version of Debian
source /etc/os-release

# Download the Microsoft repository GPG keys
wget -q$VERSION_ID/packages-microsoft-prod.deb

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Delete the Microsoft repository GPG keys file
rm packages-microsoft-prod.deb

# Update the list of packages after we added
sudo apt-get update


# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell


Differences from Windows PowerShell 5.1

Regardless of the operating system that you are using, PowerShell 7 can be started from the Terminal using "pwsh". You can still use $PSVersionTable to check the current version:



Windows PowerShell 5.1 vs. PowerShell 7

Although PowerShell 7 offers many benefits and new features, let us first take a look at some of the reasons not to upgrade. Here are the most important things to consider.


Missing cmdlets

A major shortcoming of PowerShell 7 is the absence of certain cmdlets that were available in Windows PowerShell 5.1. This is especially true for cmdlets that are Windows-specific and not supported on other platforms, such as MacOS or Linux. Here are some examples:

  • WMI-based cmdlets are not available on MacOS and Linux because the interfaces are Windows-native.
  • In order to find a common denominator across supported platforms, the implementation of cmdlets for Windows-only tools has been omitted. This affects, for example, the Windows Firewall or the EventLog.
  • Despite the presence of a TCP stack, some networking commands, such as Resolve-DNSName, are missing.

For a complete list of removed cmdlets, see the official Microsoft documentation page: Differences between Windows PowerShell 5.1 and PowerShell 7.x.


Compatibility with Windows-cmdlets

Unlike Linux and MacOS, the same cmdlets are generally available on Windows systems.This is not because Windows ships with a different version of PowerShell 7, but because PowerShell 7 scans the system and finds the PowerShell 5.1 cmdlets. To make this easier, the UseWindowsPowerShell parameter has been added to the Import-Module cmdlet. This parameter creates a proxy module in PowerShell 7 that uses a local Windows PowerShell process to implicitly run all of the cmdlets that are included in that module.For more information, see the official documentation for Import-Module.


No integrated scripting environment (ISE)

Another drawback is the lack of a native ISE alternative in PowerShell 7. Many administrators and developers are accustomed to Windows PowerShell 5.1's ISE, while PowerShell 7 relies on Visual Studio Code (VSCode) as its primary development environment. VSCode offers many advantages and is very powerful, but the transition can require some learning and is not always as seamless as the classic ISE. However, due to the improved features, community extensions, direct Git integration, and much higher quality developer experience, I generally recommend using Visual Studio Code. Visual Studio Code also supports Windows PowerShell 5.1 and is a cross-version tool for PowerShell coding.


Advantages of PowerShell 7

Now that we've looked at the downsides of PowerShell 7, let's focus on the many upsides. There are many good reasons to upgrade to the latest version.


Better performance

PowerShell 7 is faster than its predecessor in many ways. This is especially true of the Group-Object and Sort-Object cmdlets, which are now much faster. Anyone who frequently processes large amounts of data will quickly appreciate the increased efficiency.

The following sample code runs a small benchmark that illustrates the immense performance improvement in PowerShell 7. It starts by creating a large object and then grouping it using Group-Object. This grouping process is measured using the StopWatch class:

$AllFiles = Get-ChildItem -Path $home -File -Recurse -Force -ErrorAction SilentlyContinue

$stopwatch = [Diagnostics.StopWatch]::StartNew()
$suspicious = $AllFiles | Group-Object -Property Length 

$duration = $stopwatch.Elapsed.TotalSeconds
Write-Output "duration: $duration seconds"


The code works with both Windows PowerShell 5.1 and PowerShell 7 – feel free to try it out. On my virtual machine, I get the following results:


Windows PowerShell 5.1: 23 seconds

02_Windows PowerShell 5.1


PowerShell 7: 0,4 seconds

03_PowerShell 7

The example shows that PowerShell 7 is 57 times faster. Especially in large infrastructure environments or when using large data collections, switching to PowerShell 7 can provide a massive performance boost.


Parallelization made easy

One of the most powerful new features is the ability to parallelize. You can use the foreach cmdlet and the ThreadJobs module to run tasks in parallel. This means that you can perform multiple tasks at the same time, saving you a lot of time. Here is an example:

$procs = Get-Process
$procs | ForEach-Object {
    Write-Host $_.Id
    Start-Sleep -Seconds 1

In this case, all running processes are collected and their IDs are output one by one. After each output, the script waits one second. The processes are run sequentially. However, it is also possible to process multiple process IDs at the same time without much effort – in this case, the magic word is not "please", but "parallel":

$procs = Get-Process
$procs | ForEach-Object -ThrottleLimit 20 -Parallel {
    Write-Host $_.Id
    Start-Sleep -Seconds 1


This will output 20 process IDs at once, pause for one second, then output another 20 processes, and so on. The number of concurrent jobs is determined by the ThrottleLimit.


New and improved web request cmdlets

PowerShell 7 also includes many new and improved cmdlets that make your job easier. Invoke-WebRequest and Invoke-RestMethod are now more powerful and flexible, making it easier to work with Web APIs. The Test-Connection -AsJob cmdlet lets you run connection checks as background tasks, making your processes more efficient. And Test-Json lets you easily check the syntax of JSON data, which is especially useful if you work a lot with JSON files and APIs. For more information, see the official Microsoft documentation ("Test-Json").



In many organizations, people tend to prefer what is already available. This means that Windows PowerShell 5.1 is still widely used because it is preinstalled on most Windows systems. This convenience means that the transition to a new version, such as PowerShell 7, is delayed.

The ideal solution would be to integrate PowerShell 7 directly into Windows, as was done with version 5.1. This would greatly increase enterprise adoption by eliminating additional installation steps and giving IT administrators immediate access to the new features. Until this happens, the use of PowerShell 7 in many organizations will be limited to specialized applications and advanced IT departments.

Despite its many benefits, PowerShell 7 has not yet fully established itself in the broader DevOps community outside of Windows and Azure. Many users still rely on PowerShell 5.1, largely because of existing infrastructure and scripts. Therefore, a pragmatic approach is to use both versions side by side. This side-by-side approach allows you to take advantage of the new features and performance improvements in PowerShell 7 where it makes sense, while still allowing existing scripts and processes to run in the familiar environment.

So my recommendation is: Use PowerShell 7 wherever you can! Microsoft may eventually stop supporting PowerShell 5.1. Save yourself the hassle and avoid a more expensive migration later by writing scripts in version 7 now. The investment in the new version will pay off in the long run because PowerShell 7 is more future-proof and offers better performance and enhanced functionality.




Your ultimate PowerShell Cheat Sheet

Unleash the full potential of PowerShell with our handy poster. Whether you're a beginner or a seasoned pro, this cheat sheet is designed to be your go-to resource for the most important and commonly used cmdlets.

The poster is available for download and in paper form.

PowerShell Poster 2023

Get your poster here!



Related links

Related posts

14 min read

Privacy Management with PowerShell – Let's look at the core features of Priva!

All you need to know about Privacy Management, privacy management policies, rules, and subject rights requests.  


4 min read

Let's celebrate System Administrator Appreciation Day!

Every last Friday of July, we get to celebrate System Administrator Appreciation Day, a special day dedicated to...

8 min read

PowerShell 7: What are the pros and cons of switching from Windows PowerShell 5.1?

Windows PowerShell 5.1 is usually preinstalled and the default – is it worth switching to PowerShell 7, or will it lead...

About the author: