Skip to main content
powershell/PSAvoidExclaimOperator is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

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

Correct code

Configuration

Upstream PSScriptAnalyzer supports the following rule setting. tally forwards matching rules.powershell.PSAvoidExclaimOperator options to PSScriptAnalyzer.

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.