Microsoft Releases PowerShell 7
PowerShell 7 has reached the "general availability" (GA) stage, Microsoft announced this week, after being in the "release candidate" stage since December.
Initially, Microsoft had projected a January release window for PowerShell 7, though that schedule slipped several times. The product advanced to the Release Candidate 3 (RC3) stage before finally going gold.
PowerShell 7 is notable for being a cross-platform (Linux, macOS and Windows) scripting tool that attempts to bridge the gap between Windows PowerShell 5.1 and the PowerShell Core 6.x releases. In addition, while Microsoft based PowerShell 7 on the open source .NET Core 3.1, a near-term goal is to base it on a coming open source and cross-platform .NET 5 release, which is expected to roll out in November.
PowerShell 7 users will get update notifications from Microsoft. For instance, users of PowerShell 7 RC3 "should see the update notification [to the GA release] on the next restart of pwsh," explained Steve Lee, principal software engineer manager on the PowerShell team, in a Twitter post.
It's also possible to install PowerShell 7. Microsoft has published installation documents for Windows, macOS and Linux.
Microsoft previously explained that it added modules to PowerShell 7 to gain backward compatibility with most of Windows PowerShell 5.1's capabilities. It found that such lack of support in PowerShell Core 6.x releases was an apparent stumbling block for Windows PowerShell users, who seemed to be deferring upgrades.
Possibly, incompatible modules will still be a problem, even with the release of PowerShell 7. However, PowerShell 7 includes a -UseWindowsPowerShell switch for the Import-Module cmdlet that's designed "to ease the transition to PowerShell 7 for those using still incompatible modules," Microsoft's announcement explained. This switch actually creates a "proxy module in PowerShell 7 that uses a local Windows PowerShell process," it added.
Moreover, Microsoft is still continuing to beef up the module support in PowerShell 7, even after the GA release.
"For those modules still incompatible, we're working with a number of teams to add native PowerShell 7 support, including Microsoft Graph, Office 365, and more," the announcement explained.
Microsoft's use of .NET Core 3.1 with PowerShell 7 adds .NET Framework APIs, which enable "significantly more backwards compatibility with existing Windows PowerShell modules," it added.
Microsoft's announcement offered a relatively short list of some of the new features in PowerShell 7, which are more fully described in this "What's New" document. There's a simplified Get-Error cmdlet to find errors in code. A compatibility layer adds support for Windows PowerShell modules.
The ForEach-Object cmdlet now has a new -Parallel parameter option. Microsoft's document included a demo script that's described as using the -Parallel parameter to pull down "50,000 log entries from 5 system logs on a local Windows machine."
Microsoft added new "pipeline chain operators" in PowerShell 7. The && operator serves as AND, while the || operator functions as OR, when adding conditions to chain pipelines. It works similarly to Bash or Zsh shells.
Additionally, Microsoft added a couple of null conditional operators in PowerShell 7. The ?? null coalescing operator returns "the value of its left-hand operand if it isn't null." The ??= null conditional assignment operator "assigns the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to null."
If that weren't enough, there's a new ternary operator that works like an if-else statement. Microsoft's example is:
<condition> ? <if-true> : <if-false>
PowerShell 7 also has a new cmdlet that's used to invoke desired state configuration (DSC) resources, but it's just an "experimental" feature right now.
More description on PowerShell 7's new features can be found in this post by Thomas Mauer, a senior cloud advocate at Microsoft.
PowerShell 7's Lifecycle and Support
PowerShell 7 is a so-called "long-term servicing" release that's supported for three years from Dec. 3, 2019, which was the release date of .NET Core 3.1. PowerShell 7 follows the lifecycle of .NET Core, and it's based on the Microsoft Modern Lifecycle support policy.
While three years of support may sound somewhat reassuring, the Microsoft Modern Lifecycle support policy comes with requirements to keep PowerShell 7 updated with patches within 30 days of release to stay supported. In addition, users of PowerShell 7 must upgrade to a minor product update within six months of release to stay supported. Microsoft only has to provide a 12 months' advance notice before ending product support.
These sorts of support details are described in this "PowerShell Core Support Lifecycle" document.
PowerShell 7, being a long-term servicing release, is on a separate channel from other types of PowerShell releases, so "if you are on 7.0-LTS, when 7.1 comes out, you won't get an update notification," Lee explained in another Twitter post.
PowerShell 7 follows an open source MIT license, which permits code contributions. Technical support just comes from the PowerShell 7 community, although "PowerShell Core is supported under traditional Microsoft support agreements," Microsoft's document explained.
Kurt Mackie is senior news producer for 1105 Media's Converge360 group.