Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 722 Bytes

AvoidExclaimOperator.md

File metadata and controls

48 lines (33 loc) · 722 Bytes
description ms.date ms.topic title
Avoid exclaim operator
03/26/2024
reference
AvoidExclaimOperator

AvoidExclaimOperator

Severity Level: Warning

Description

Avoid using the negation operator (!). Use -not for improved readability.

Note

This rule is not enabled by default. The user needs to enable it through settings.

How to Fix

Example

Wrong

$MyVar = !$true

Correct

$MyVar = -not $true

Configuration

Rules = @{
    PSAvoidExclaimOperator  = @{
        Enable = $true
    }
}

Parameters

  • Enable: bool (Default value is $false)

    Enable or disable the rule during ScriptAnalyzer invocation.