{"id":19758,"date":"2022-10-24T10:49:19","date_gmt":"2022-10-24T18:49:19","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=19758"},"modified":"2022-10-24T10:49:19","modified_gmt":"2022-10-24T18:49:19","slug":"psscriptanalyzer-pssa-1-21-0-has-been-released","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/psscriptanalyzer-pssa-1-21-0-has-been-released\/","title":{"rendered":"PSScriptAnalyzer (PSSA) 1.21.0 has been released"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>We are happy to announce the release of PSScriptAnalyzer 1.21. This minor version update includes:<\/p>\n<ul>\n<li>Three new rules<\/li>\n<li>Enhances one rule<\/li>\n<li>Pipeline support to <code>Invoke-Formatter<\/code><\/li>\n<li>Four bug fixes<\/li>\n<li>Improved message details in <code>PSUseCorrectCasing<\/code><\/li>\n<li>Lots of documentation updates<\/li>\n<li>Updated system requirements<\/li>\n<\/ul>\n<p>A big portion of changes are in less visible areas such as the maintenance of dependencies and CI.<\/p>\n<h2>System requirements<\/h2>\n<p>Starting with this version the minimum requirements are changing as follows:<\/p>\n<ul>\n<li>For PowerShell &#8216;Core&#8217; users (<code>$PSVersionTable.PSEdition -eq 'Core'<\/code>):\n<p>The minimum required PowerShell version increases from <code>7.0.3<\/code> to <code>7.0.11<\/code>. With PowerShell 7.0\nreached end of life this December, the next version of PSScriptAnalyzer will require <code>7.2<\/code>.<\/p>\n<p>Use <code>$PSVersionTable.PSVersion<\/code> to see which version of PowerShell you are using. For more\ninformation about supported versions of PowerShell, see the\n<a href=\"https:\/\/docs.microsoft.com\/powershell\/scripting\/install\/powershell-support-lifecycle#powershell-end-of-support-dates\">PowerShell support lifecycle<\/a>.<\/li>\n<li>For Windows PowerShell users (version 3 to 5.1 or (<code>$PSVersionTable.PSEdition -ne 'Core')<\/code>)\n<p>The minimum required version of the .NET Framework runtime increased from <code>4.5.2<\/code> to <code>4.6.2<\/code>.\nVersions <code>4.5.2.<\/code>, <code>4.6<\/code> and <code>4.6.1<\/code> have reached end of support this year. This change should not\nimpact the majority of users on supported and patched OS versions.<\/p>\n<p>For more details about .NET support, see\n<a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/net-framework-4-5-2-4-6-4-6-1-will-reach-end-of-support-on-april-26-2022\">.NET Framework blog post<\/a>.<\/li>\n<\/ul>\n<p>For more information, see the full <a href=\"https:\/\/github.com\/PowerShell\/PSScriptAnalyzer\/blob\/master\/CHANGELOG.MD\">changelog<\/a>.<\/p>\n<h2>New Rules<\/h2>\n<h3>AvoidMultipleTypeAttributes<\/h3>\n<p>This rule is to call out the usage of multiple type attributes in a function that the parser accepts\nas valid syntax but can later cause unexpected behavior or an error at runtime.<\/p>\n<p>For example, the following function<\/p>\n<pre><code class=\"language-powershell\">function foo { [switch][string] $Param1 }<\/code><\/pre>\n<p>will throw the following error when the function is invoked:<\/p>\n<blockquote><p>Cannot convert the &#8220;&#8221; value of type &#8220;System.String&#8221; to type &#8220;System.Management.Automation.SwitchParameter&#8221;<\/p><\/blockquote>\n<p>Thanks to GitHub user <a href=\"https:\/\/github.com\/hankyi95\">hankyi95<\/a> for contributing this rule.<\/p>\n<h3>AvoidSemicolonsAsLineTerminators<\/h3>\n<p>The rule detects the usage of a trailing semicolon at the end of a line, which is not required in\nmost PowerShell scripts and can be omitted. This rule is not enabled by default and can be used by\n<code>Invoke-Formatter<\/code>.<\/p>\n<p>The latest Preview version of the PowerShell extension for Visual Studio Code already includes\nPSScriptAnalyzer 1.21.0 and can control this formatting rule via a new\n<code>powershell.codeFormatting.avoidSemicolonsAsLineTerminators<\/code> setting. This should soon be available\nin the non-preview version of the extension as well.<\/p>\n<p>Thanks to Aliaksei (GitHub user <a href=\"https:\/\/github.com\/tempora-mutantur\">tempora-mutantur<\/a>) for contributing this rule.<\/p>\n<h3>AvoidUsingBrokenHashAlgorithms<\/h3>\n<p>This rule inspects the <a href=\"https:\/\/docs.microsoft.com\/powershell\/module\/microsoft.powershell.utility\/get-filehash\">Get-FileHash<\/a> cmdlet for usage of either <code>MD5<\/code> or <code>SHA-1<\/code> as the value\nto the <a href=\"https:\/\/docs.microsoft.com\/powershell\/module\/microsoft.powershell.utility\/get-filehash#-algorithm\">-Algorithm<\/a> parameter since those algorithms are no longer considered secure. Users\nshould consider replacing the value with <code>SHA256<\/code>, <code>SHA384<\/code>, <code>SHA512<\/code>, or other safer algorithms\nwhere possible. It is understood there will be legacy or backwards compatibility cases where this\ncannot be done. PSScriptAnalyzer has a <a href=\"https:\/\/docs.microsoft.com\/powershell\/utility-modules\/psscriptanalyzer\/using-scriptanalyzer#suppressing-rules\">suppression feature<\/a> that can be used to document the\nreason for it in your code.<\/p>\n<p>Thanks to Michael Van Leeuwen (GitHub user <a href=\"https:\/\/github.com\/MJVL\">MJVL<\/a>) for contributing this rule.<\/p>\n<h2>Enhancements<\/h2>\n<p><code>Invoke-Formatter<\/code> now accepts input via the pipeline, either just as a string or\n<code>[pscustomobject]<\/code> with parameter values.<\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/powershell\/utility-modules\/psscriptanalyzer\/rules\/avoidusingplaintextforpassword\">AvoidUsingPlainTextForPassword<\/a> rule is the first built-in rule to now return more than one\nsuggestion for correction. In addition to suggesting the usage of <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/system.security.securestring\">SecureString<\/a>, it now offers\nan alternative suggestion with <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/system.management.automation.pscredential\">PSCredential<\/a>.<\/p>\n<p>With version 2.40.0 of the <code>az<\/code> CLI, its entrypoint changed from a batch script to an <code>az.ps1<\/code>\nscript. Since this script just passed its received arguments as <code>$args<\/code> as-is to python, it is still\na CLI and not a script with parameters. But it causes now a <a href=\"https:\/\/learn.microsoft.com\/powershell\/utility-modules\/psscriptanalyzer\/rules\/AvoidUsingPositionalParameters\">AvoidUsingPositionalParameters<\/a>\nwarning, which is a false positive. We therefore added a <code>CommandAllowList<\/code> configuration to it,\nwhich has <code>az<\/code> in it by default.<\/p>\n<h2>Documentation changes<\/h2>\n<p>In order to keep documentation all consolidated in one location, we have moved the documentation in\nthe repo to the repo of <a href=\"https:\/\/github.com\/MicrosoftDocs\/PowerShell-Docs\">docs.microsoft.com<\/a>. Please see the <a href=\"https:\/\/github.com\/PowerShell\/PSScriptAnalyzer#documentation-notice\">documentation notice<\/a> in the\nrepo in order to get more specific details.<\/p>\n<h2>Outlook<\/h2>\n<p>Expect more formatting rules and options in the next release and continue giving us feedback. We are\nlooking to increase our release frequency now that the Microsoft internal build has moved to a new\nsystem, which is what caused some delay to this release. To reduce maintenance, we are looking to\ndrop support for PowerShell version 3 and 4 in future versions of PSScriptAnalyzer, which would also\nalign it with the PowerShell extension for Visual Studio Code where this change was successful. The\nfirst step could be to increase the value of the <code>PowerShellVersion<\/code> property in the module manifest\nbut still ship the version specific binaries so that it would still work if one changed its value in\nthe manifest.<\/p>\n<p>On behalf of the Script Analyzer team,<\/p>\n<p><a href=\"https:\/\/twitter.com\/cbergmeister\">Christoph Bergmeister<\/a>, Project Maintainer from the community, <a href=\"https:\/\/www.avanade.com\">Avanade<\/a><\/p>\n<p><a href=\"https:\/\/twitter.com\/jwtruher\">Jim Truher<\/a>, Senior Software Engineer, <a href=\"https:\/\/twitter.com\/PowerShell_Team\">PowerShell Team<\/a>, <a href=\"https:\/\/www.microsoft.com\">Microsoft<\/a><\/p>\n<p><!-- link references --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Announcing the release of PSScriptAnalyzer 1.21<\/p>\n","protected":false},"author":2413,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3182],"class_list":["post-19758","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-psscriptanalyzer"],"acf":[],"blog_post_summary":"<p>Announcing the release of PSScriptAnalyzer 1.21<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19758","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\/2413"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=19758"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19758\/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=19758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=19758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=19758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}