On December 15, 2020, Microsoft's PowerShell development team released PowerShell 7.2 Preview 2 to GitHub. Learn what's new and what's changed in this build, and receive some guidance concerning prerelease PowerShell. If you're the kind of systems administrator who likes to "kick the tires" with prerelease software to get a head start on new functionality, then read on!

About PowerShell releases ^

According to Microsoft's PowerShell Support Lifecycle, PowerShell releases have different servicing (that is, updating) approaches attached to them. Specifically:

  • Long-Term Support (LTS): These are generally available (GA) PowerShell releases that are fully supported by Microsoft for a predescribed time period. Furthermore, Microsoft makes only critical security and bug fixes to minimize the impact on your existing workloads.
  • Current Release: This is the most recent PowerShell GA release, but includes a much more frequent update cadence. Microsoft's updates here embrace security patches, bug fixes, and new features.
  • Preview: A Preview build is normally covered only under what Microsoft calls "community support." That is, you'll need to rely on non-Microsoft technical professionals for potential answers.

Of course, in your production environments, you'll likely want to stick with PowerShell LTS releases. However, it can be useful to test Preview builds on your development workstation to see what's on the PowerShell team's feature roadmap.

One more preliminary point: PowerShell 7.2 will eventually rely on .NET 6, but Preview 2 remains bound to .NET 5 because .NET 6 hasn't yet reached Preview status as of this writing in late December 2020.

Language refinements ^

Remember that PowerShell 7 is open-sourced at GitHub. This means we can review (and submit) issues to the codebase and follow them through to resolution.

In PowerShell 7.2 Preview 2, the biggest code changes come in the form of code cleanup; feel free to review the issue list and have a look at how the PowerShell community positively impacts the PowerShell language.

I can't overstate how impressive and powerful it is to say that community members like you and I can contribute to the PowerShell 7 codebase! Having been a Microsoft specialist since 1997, it wasn't too long ago when the notion of a community member's code changes being merged into a Microsoft production codebase was virtually unthinkable.

Breaking change bug fix ^

Joel Sallow, author of the wonderful PSKoans PowerShell learning project, submitted a bug fix for a breaking change involving the -PipelineVariable common parameter. In a nutshell, prior PowerShell 7.x versions didn't include all pipeline data in -PipelineVariable. Specifically, it carried only the first element.

Ilya Sazonov, a highly active PowerShell contributor, issued a fix for a bug in PowerShell 7.1 that raised an error when an attempt was made to run an executable program file on a non-NTFS drive. The problem here concerned how PowerShell handled (the lack of) reparse points; reparse points in NTFS allow the file system to redirect input/output requests. For instance, think of viewing cloud-only OneDrive files in your local OneDrive desktop application.

The PowerShell development team said they would backport this fix to PowerShell 7.1 during their next servicing cycle.

New feature ^

You might be familiar with the Write-Host cmdlet's -ForegroundColor and -BackgroundColor parameters. When you're running PowerShell in a terminal window, text formatting can be helpful to draw your attention to particular output.

PowerShell 7.2 Preview 1 now includes a $PSStyle automatic variable that enables you to access ANSI escape codes, including foreground/background color, italics, bold, and so forth.

Accessing ANSI escape codes via PowerShell

Accessing ANSI escape codes via PowerShell

Note that in the previous screenshot, some $PSStyle members include nested elements. You can also link multiple style elements together, as shown in the next image:

Decorating PowerShell output text

Decorating PowerShell output text

Note that when I tested $PSStyle on my iMac, it wouldn't work in Visual Studio Code's integrated terminal. However, it worked fine in a PowerShell console window. It should come as no surprise to you that somebody already raised this issue at GitHub.

I'm colorblind, so I have a difficult time seeing much of any color. However, I'd love to be able to style hyperlinks so they are more apparent in the PowerShell console. To that point, I'd love to see something like the following implemented someday:

$PSStyle.FormatHyperlink("4sysops website", "https://4sysops.com")

Wrap-up ^

Although PowerShell 7.2 Preview 1 isn't a revolutionary prerelease, I hope at the least I got you thinking about some fundamental patterns:

  • PowerShell releases are aligned to particular .NET Core versions.
  • Use the LTS or perhaps the Current Release PowerShell versions in your production environment.
  • Preview PowerShell builds include experimental features that enable you to test functionality long before it reaches the GA product.
  • Because PowerShell is open source, you are free to raise issues and lodge feature requests to the Microsoft product team. They truly value your feedback and use it to guide the PowerShell roadmap!

Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account