{"id":18790,"date":"2020-12-15T16:08:04","date_gmt":"2020-12-16T00:08:04","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=18790"},"modified":"2020-12-16T08:13:55","modified_gmt":"2020-12-16T16:13:55","slug":"powershell-7-2-preview-2-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/powershell-7-2-preview-2-release\/","title":{"rendered":"PowerShell 7.2 Preview 2 release"},"content":{"rendered":"<h2>PowerShell 7.2 Preview 2<\/h2>\n<p>Today we are proud to announce the <a>second preview release of PowerShell 7.2<\/a>.\nThis preview is still based on .NET 5 as we wait for the first preview of .NET 6 which we expect PowerShell 7.2 to be based upon.<\/p>\n<p>This preview includes many changes including code cleanup, bug fixes, and a few new features.<\/p>\n<h2>Code cleanup<\/h2>\n<p>The community has made significant <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/pulls?q=is%3Apr+sort%3Aupdated-desc+milestone%3A7.2.0-preview.2+is%3Amerged+label%3ACL-CodeCleanup+\">contributions to code cleanup<\/a>\nwhich is a focus early in a new release.\nApproximately two thirds of the 120 pull requets were for code cleanup!<\/p>\n<p>Thanks to all the community members involved in submitting pull requests and reviewing them!<\/p>\n<h2>Notable bug fixes<\/h2>\n<p>Although we appreciate all bug fixes from the community, there are a few I believe have a broader impact and worth mentioning.<\/p>\n<h3>Correct handling of Windows invalid reparse points<\/h3>\n<p>On Windows, <a href=\"https:\/\/docs.microsoft.com\/windows\/win32\/fileio\/reparse-points\">reparse points<\/a> are a collection of user-defined data that define specific filesystem behaviors.\nFor example, symbolic links, OneDrive files, and Microsoft installed applications use reparse points.\nDue to a bug introduced in PowerShell 7.1, if you try to use an executable on a drive that isn&#8217;t NTFS, you&#8217;ll get an <code>Incorrect Function<\/code> error.\nThis can be a local USB drive or a network share, for example.<\/p>\n<p>Thanks to our community maintainer <a href=\"https:\/\/github.com\/iSazonov\">Ilya Sazonov<\/a> for the <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/pull\/13634\">fix<\/a>.<\/p>\n<p>We expect to backport this fix to PowerShell 7.1 for the next servicing release.<\/p>\n<h2>Breaking changes<\/h2>\n<h3><code>-PipelineVariable<\/code> common parameter<\/h3>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/powershell\/module\/microsoft.powershell.core\/about\/about_commonparameters#pipelinevariable\">-PipelineVariable<\/a> common parameter\nnow correctly contains all the objects passed in from the pipeline making script cmdlets work the same as C# cmdlets instead of just the first input object.<\/p>\n<p>You can see an example of the change in behavior in the original <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\/10932\">issue<\/a>.<\/p>\n<p>Thanks to <a href=\"https:\/\/github.com\/vexx32\">Joel Sallow<\/a> for the <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/pull\/12766\">fix<\/a>.<\/p>\n<h2>New features<\/h2>\n<h3><code>$PSStyle<\/code> automatic variable for ANSI rendering<\/h3>\n<p>When working in the console with a <a href=\"https:\/\/www.microsoft.com\/p\/windows-terminal\/9n0dx20hk701\">modern terminal<\/a>, color and text effects can help\nmake text information more interesting and useful.<\/p>\n<p>This experimental feature called <code>PSAnsiRendering<\/code> exposes a new <code>$PSStyle<\/code> automatic variable that can be used for two different purposes.<\/p>\n<p>The first is to make it easier to author text content that contains <a href=\"https:\/\/en.wikipedia.org\/wiki\/ANSI_escape_code\">ANSI escape codes<\/a> which control\ntext decorations like color, bold, italics, etc&#8230;<\/p>\n<p>This example simply dumps the contents of <code>$PSStyle<\/code> and shows you the members you can use and their effect on text as well as the actual ANSI escape sequence.\nNote that the custom formatting for this variable includes nested types like <code>Formatting<\/code>, <code>Foreground<\/code>, and <code>Background<\/code>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2020\/12\/PSStyle-output.png\" alt=\"$PSStyle variable\" \/><\/p>\n<p>You can use multiple ANSI escape sequences together.\nIn this example, I&#8217;ve set warning messages to have bold and italicized yellow text on a magenta background:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2020\/12\/Update-warning.png\" alt=\"Warning message style customization\" \/><\/p>\n<p>There are also <code>FromRgb()<\/code> methods available to make use of full 24-bit color if your terminal supports it:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2020\/12\/String-FromRGB.png\" alt=\"24-bit color text\" \/><\/p>\n<p>C# module authors can also leverage <code>$PSStyle<\/code> by using the <code>PSStyle<\/code> singleton class in the <code>System.Management.Automation<\/code> namespace:<\/p>\n<pre><code class=\"csharp\">string text = $\"{PSStyle.Instance.Reverse}{PSStyle.Instance.Foreground.Green}PowerShell{PSStyle.Instance.Foreground.Yellow} Rocks!{PSStyle.Instance.Reset}\";\r\n<\/code><\/pre>\n<p>You can control how PowerShell outputs strings that contain ANSI escape sequences by setting <code>$PSStyle.OutputRendering<\/code>:<\/p>\n<ul>\n<li><em>Automatic<\/em>\nThis is the default and currently will output the text as-is whether it is to the host or through the pipeline if the\nterminal supports ANSI escape sequences (otherwise the output will be plaintext). This is similar behavior to what you\nwould get on Linux.<\/li>\n<li><em>Ansi<\/em>\nThis value will output the text as-is whether it is to the host or through the pipeline.<\/li>\n<li><em>PlainText<\/em>\nThis value will remove ANSI escape sequences from any text output whether it is to the host or through the pipeline.<\/li>\n<li><em>Host<\/em>\nThis value will output the text as-is if sent to the host if ANSI escape sequences are supported, but will output plaintext\nif the output is sent through the pipeline or redirected. This is similar behavior to what you would get on macOS.<\/li>\n<\/ul>\n<p>As this is an experimental feature, we encourage feedback on this before we make a decision to take it out of experimental.\nSee the original <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\/13071\">issue<\/a> for additional details, but open new issues if you have any problems or\nsuggestions on how to improve this feature.<\/p>\n<p>We very much appreciate on going feedback on our preview releases so we can make adjustments before the release is finalized.\nPlease participate in on <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\">going discussions<\/a> or create new issues in our repo.<\/p>\n<p>Thanks again to the PowerShell community and all the amazing contributors!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Important changes included in the PowerShell 7.2 Preview 2 release<\/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":[248],"class_list":["post-18790","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"acf":[],"blog_post_summary":"<p>Important changes included in the PowerShell 7.2 Preview 2 release<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18790","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=18790"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/18790\/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=18790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=18790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=18790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}