Skip to main content

Documentation Index

Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt

Use this file to discover all available pages before exploring further.

powershell/PSAvoidExclaimOperator is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
PropertyValue
SeverityWarning
CategoryPSScriptAnalyzer
Auto-fixNo

Description

Avoid using the negation operator (!). Use -not for improved readability.
Upstream PSScriptAnalyzer does not enable this rule by default. Configure rules.powershell.PSAvoidExclaimOperator.Enable = true to forward the upstream setting to PSScriptAnalyzer.

How to Fix

Replace the ! negation operator with the PowerShell -not operator.

Examples

Problematic code

$MyVar = !$true

Correct code

$MyVar = -not $true

Configuration

Upstream PSScriptAnalyzer supports the following rule setting. tally forwards matching rules.powershell.PSAvoidExclaimOperator options to PSScriptAnalyzer.
Rules = @{
    PSAvoidExclaimOperator  = @{
        Enable = $true
    }
}

Parameters

  • Enable: bool (Default value is $false) Enable or disable the rule during ScriptAnalyzer invocation.

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for AvoidExclaimOperator, licensed under CC BY 4.0.