PowerShell 7 Preview 4
We continue to make progress towards our PowerShell 7 release which currently is targeting December 2019 for a Release Candidate and January 2020 for General Availability and will be our first LTS (Long Term Servicing) release!
Please see the previous blog post on Preview 3 for more details about LTS and also Windows PowerShell compatibility.
Preview 4 contains a number of bug fixes, but also new features which I’ll cover in this blog post.
New Experimental Features in Preview 4
This is just a small part of the entire changelog. New experimental features in this preview from the community and also the PowerShell team:
The ternary operator is popular among C# developers due to its terseness which can improve readability if you are familiar with this operator.
This operator is completely opt-in so if you prefer to use if..else instead, you can certainly continue to do that.
Those of you familiar with the Start-Job cmdlet will have encountered that the new PowerShell process started to handle the job will have different working directory on Windows PowerShell and PowerShell Core and it can sometimes be not what you expected. This parameter was added to allow you to specify the working directory of the new job process before your script block runs!
$ErrorActionPreference = “Break”
This feature comes from a well known PowerShell MVP Kirk Munro. Basically, if you set
Break, then when there is an error it will drop you into the debugger immediately!
With this change, you can now leverage DSC Resources while by-passing the LCM (Local Configuration Manager). This means that you can author your own LCM or simply leverage existing DSC Resources within your scripts and this also works cross platform!
Note that binary DSC Resources are not supported!
DSC Configuration Compilation
Previously if you authored a DSC Configuration script, you would need to use a Windows machine to compile it to a mof file to deploy onto your managed node. Starting with Preview4, you can now perform DSC compilation on non-Windows systems.
Note that this is work in progress with some known issues.
Testing the MSIX package
Recently, we started publishing a MSIX package for Windows. This will eventually allow us to publish PowerShell 7 to the Windows Store. For now, if you wish to try out this package, you must be in Developer Mode and use
Add-AppxPackage to install it. Double clicking it from the Windows Shell will not allow you to install the developer signed package.
In Preview3 we announced that Experimental Features would be enabled by default. The way this was done is to create a system wide
powershell.config.json file listing each of the Experimental Features which would make them enabled. However, if you had previously explicitly enabled Experimental Features, then you would have created a user specific
powershell.config.json which would take precedence which means that any features you didn’t explicitly enable would be disabled.
To get all Experimental Features, you can:
Get-ExperimentalFeature | Enable-ExperimentalFeature
or delete your user specific
powershell.config.json (assuming you didn’t put any other specific configuration settings in that file).
Although this blog post focuses on new features, this release also contains many bug fixes as well as targeted performance improvements.
You can always get the latest version of PowerShell from https://aka.ms/get-powershell.
Expect more new features from the community and the PowerShell team in future Preview releases!
Steve Lee PowerShell Team