SuppressMessageAttribute

noun

say it: “suh-PRES MES-ij AT-ruh-byoot” /səˈprɛs ˈmɛsɪdʒ ˈætrəˌbjut/

A line above a PowerShell function's parameters that tells the script checker to skip one rule there, with a reason.

What is SuppressMessageAttribute?

SuppressMessageAttribute tells PSScriptAnalyzer "I broke this rule here on purpose". It goes above param() in one function, names the rule, and gives a reason, so the next person knows it wasn't a slip.

function Show-Report {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colored lines for the screen only')]
    param()
    Write-Host 'Done' -ForegroundColor Green
}

In a sentence

  • “Sam used SuppressMessageAttribute to allow Write-Host in the one function that colors the screen.”
  • “The SuppressMessageAttribute says why the rule was set aside.”

Level: Freelancer · More PowerShell terms at this level

Updated