{"id":18019,"date":"2019-09-19T09:59:03","date_gmt":"2019-09-19T17:59:03","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=18019"},"modified":"2019-09-20T06:52:00","modified_gmt":"2019-09-20T14:52:00","slug":"powershell-7-preview-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/powershell-7-preview-4\/","title":{"rendered":"PowerShell 7 Preview 4"},"content":{"rendered":"<div class=\"markdown-body\">\n<p>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!<\/p>\n<p>Please see the previous blog post on <a href=\"https:\/\/devblogs.microsoft.com\/powershell\/powershell-7-preview-3\/\" rel=\"nofollow\">Preview 3<\/a> for more details about LTS and also Windows PowerShell compatibility.<\/p>\n<p><a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/pulls?q=is%3Apr+milestone%3A7.0.0-preview.4+is%3Aclosed\">Preview 4<\/a> contains a number of bug fixes, but also new features which I&#8217;ll cover in this blog post.<\/p>\n<h2><a id=\"user-content-new-features-in-preview-4\" class=\"anchor\" href=\"#new-features-in-preview-4\" aria-hidden=\"true\"><\/a>New Experimental Features in Preview 4<\/h2>\n<p>This is just a small part of the entire <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/releases\">changelog<\/a>. New experimental features in this preview from the community and also the PowerShell team:<\/p>\n<h3><a id=\"user-content-ternary-operator\" class=\"anchor\" href=\"#ternary-operator\" aria-hidden=\"true\"><\/a>Ternary Operator<\/h3>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/operators\/conditional-operator\" rel=\"nofollow\">ternary operator<\/a> is popular among C# developers due to its terseness which can improve readability if you are familiar with this operator.<\/p>\n<p>This operator is completely opt-in so if you prefer to use if..else instead, you can certainly continue to do that.<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/d55144439c4b712a94d149fa0712d56cecb93daf\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f7465726e6172795f333233392e676966\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" style=\"max-width: 100%;\" src=\"https:\/\/camo.githubusercontent.com\/d55144439c4b712a94d149fa0712d56cecb93daf\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f7465726e6172795f333233392e676966\" alt=\"gif\" data-canonical-src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2019\/09\/ternary_3239.gif\" \/><\/a><\/p>\n<h3><a id=\"user-content-start-job--workingdirectory\" class=\"anchor\" href=\"#start-job--workingdirectory\" aria-hidden=\"true\"><\/a>Start-Job -WorkingDirectory<\/h3>\n<p>Those of you familiar with the <a href=\"https:\/\/docs.microsoft.com\/powershell\/module\/microsoft.powershell.core\/start-job?view=powershell-7\" rel=\"nofollow\">Start-Job<\/a> 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!<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/9ba00e8131b53124cca504fc2cc92a38b5ee6c3d\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f73746172742d6a6f622d776f726b696e676469726563746f72792e676966\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" style=\"max-width: 100%;\" src=\"https:\/\/camo.githubusercontent.com\/9ba00e8131b53124cca504fc2cc92a38b5ee6c3d\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f73746172742d6a6f622d776f726b696e676469726563746f72792e676966\" alt=\"gif\" data-canonical-src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2019\/09\/start-job-workingdirectory.gif\" \/><\/a><\/p>\n<h3><a id=\"user-content-erroractionpreference--break\" class=\"anchor\" href=\"#erroractionpreference--break\" aria-hidden=\"true\"><\/a>$ErrorActionPreference = &#8220;Break&#8221;<\/h3>\n<p>This feature comes from a well known PowerShell MVP <a href=\"https:\/\/twitter.com\/poshoholic\" rel=\"nofollow\">Kirk Munro<\/a>. Basically, if you set <code>$ErrorActionPreference<\/code> to <code>Break<\/code>, then when there is an error it will drop you into the debugger immediately!<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/77d565f7815d8669b1fbaf79cfbecdf055097c94\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f4572726f72416374696f6e427265616b2e676966\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" style=\"max-width: 100%;\" src=\"https:\/\/camo.githubusercontent.com\/77d565f7815d8669b1fbaf79cfbecdf055097c94\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f4572726f72416374696f6e427265616b2e676966\" alt=\"gif\" data-canonical-src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2019\/09\/ErrorActionBreak.gif\" \/><\/a><\/p>\n<h3><a id=\"user-content-invoke-dscresource\" class=\"anchor\" href=\"#invoke-dscresource\" aria-hidden=\"true\"><\/a>Invoke-DscResource<\/h3>\n<p>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!<\/p>\n<p>Note that binary DSC Resources are not supported!<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/2a6ec02fddc847fb23ddb75495750453504d3e8d\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f696e766f6b656473637265736f757263652e676966\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" style=\"max-width: 100%;\" src=\"https:\/\/camo.githubusercontent.com\/2a6ec02fddc847fb23ddb75495750453504d3e8d\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f696e766f6b656473637265736f757263652e676966\" alt=\"gif\" data-canonical-src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2019\/09\/invokedscresource.gif\" \/><\/a><\/p>\n<h3><a id=\"user-content-dsc-configuration-compilation\" class=\"anchor\" href=\"#dsc-configuration-compilation\" aria-hidden=\"true\"><\/a>DSC Configuration Compilation<\/h3>\n<p>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.<\/p>\n<p>Note that this is work in progress with some known issues.<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/2ed5d319eb5ef849b883c7f8ca0e33ffab4c95da\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f647363636f6d70696c652e676966\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" style=\"max-width: 100%;\" src=\"https:\/\/camo.githubusercontent.com\/2ed5d319eb5ef849b883c7f8ca0e33ffab4c95da\/687474703a2f2f646576626c6f67732e6d6963726f736f66742e636f6d2f706f7765727368656c6c2f77702d636f6e74656e742f75706c6f6164732f73697465732f33302f323031392f30392f647363636f6d70696c652e676966\" alt=\"gif\" data-canonical-src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2019\/09\/dsccompile.gif\" \/><\/a><\/p>\n<h2><a id=\"user-content-testing-the-msix-package\" class=\"anchor\" href=\"#testing-the-msix-package\" aria-hidden=\"true\"><\/a>Testing the MSIX package<\/h2>\n<p>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 <code>Add-AppxPackage<\/code> to install it. Double clicking it from the Windows Shell will not allow you to install the developer signed package.<\/p>\n<h2><a id=\"user-content-experimental-features\" class=\"anchor\" href=\"#experimental-features\" aria-hidden=\"true\"><\/a>Experimental Features<\/h2>\n<p>In Preview3 we announced that Experimental Features would be enabled by default. The way this was done is to create a system wide <code>powershell.config.json<\/code> 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 <code>powershell.config.json<\/code> which would take precedence which means that any features you didn&#8217;t explicitly enable would be disabled.<\/p>\n<p>To get all Experimental Features, you can:<\/p>\n<div class=\"highlight highlight-source-powershell\"><code>Get-ExperimentalFeature | Enable-ExperimentalFeature<\/code><\/div>\n<p>&nbsp;<\/p>\n<p>or delete your user specific <code>powershell.config.json<\/code> (assuming you didn&#8217;t put any other specific configuration settings in that file).<\/p>\n<h2><a id=\"user-content-closing\" class=\"anchor\" href=\"#closing\" aria-hidden=\"true\"><\/a>Closing<\/h2>\n<p>Although this blog post focuses on new features, this release also contains many bug fixes as well as targeted performance improvements.<\/p>\n<p>You can always get the latest version of PowerShell from <a href=\"https:\/\/aka.ms\/get-powershell\" rel=\"nofollow\">https:\/\/aka.ms\/get-powershell<\/a>.<\/p>\n<p>Expect more new features from the community and the PowerShell team in future Preview releases!<\/p>\n<p>Steve Lee\nPowerShell Team<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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. [&hellip;]<\/p>\n","protected":false},"author":685,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-18019","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>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. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/685"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=18019"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18019\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=18019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=18019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=18019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}