Edit

PSScriptAnalyzer Rules

The PSScriptAnalyzer module includes the following built-in rule definitions. For rules that support settings, you can enable or disable them by setting the Enable configuration property in a custom settings file. Rules listed as Always enabled don't expose a per-rule Enable property. There are two ways to avoid using these rules:

  • Create a custom rule configuration file to include only the rules you want or exclude the rules you don't want.
  • Add the appropriate rule suppression attributes to your code to suppress the rule for specific code blocks. For more information, see the Suppressing rules section of Using PSScriptAnalyzer.
Rule Severity Default state Configurable
AlignAssignmentStatement Warning Disabled Yes
AvoidAssignmentToAutomaticVariable Warning Always enabled
AvoidDefaultValueForMandatoryParameter Warning Always enabled
AvoidDefaultValueSwitchParameter Warning Always enabled
AvoidExclaimOperator Warning Disabled Yes
AvoidGlobalAliases Warning Always enabled
AvoidGlobalFunctions Warning Always enabled
AvoidGlobalVars Warning Always enabled
AvoidInvokingEmptyMembers Warning Always enabled
AvoidLongLines Warning Disabled Yes
AvoidMultipleTypeAttributes Warning Always enabled
AvoidNullOrEmptyHelpMessageAttribute Warning Always enabled
AvoidOverwritingBuiltInCmdlets Warning Enabled Yes
AvoidReservedWordsAsFunctionNames Warning Always enabled
AvoidSemicolonsAsLineTerminators Warning Disabled Yes
AvoidShouldContinueWithoutForce Warning Always enabled
AvoidTrailingWhitespace Warning Always enabled
AvoidUsingAllowUnencryptedAuthentication Warning Always enabled
AvoidUsingBrokenHashAlgorithms Warning Always enabled
AvoidUsingCmdletAliases Warning Always enabled Yes
AvoidUsingComputerNameHardcoded Error Always enabled
AvoidUsingConvertToSecureStringWithPlainText Error Always enabled
AvoidUsingDeprecatedManifestFields Warning Always enabled
AvoidUsingDoubleQuotesForConstantString Information Disabled Yes
AvoidUsingEmptyCatchBlock Warning Always enabled
AvoidUsingInvokeExpression Warning Always enabled
AvoidUsingPlainTextForPassword Warning Always enabled
AvoidUsingPositionalParameters Warning Always enabled
AvoidUsingUsernameAndPasswordParams Error Always enabled
AvoidUsingWMICmdlet Warning Always enabled
AvoidUsingWriteHost Warning Always enabled
DSCDscExamplesPresent Information Always enabled
DSCDscTestsPresent Information Always enabled
DSCReturnCorrectTypesForDSCFunctions Information Always enabled
DSCStandardDSCFunctionsInResource Error Always enabled
DSCUseIdenticalMandatoryParametersForDSC Error Always enabled
DSCUseIdenticalParametersForDSC Error Always enabled
DSCUseVerboseMessageInDSCResource Error Always enabled
MisleadingBacktick Warning Always enabled
MissingModuleManifestField Warning Always enabled
PlaceCloseBrace Warning Disabled Yes
PlaceOpenBrace Warning Disabled Yes
PossibleIncorrectComparisonWithNull Warning Always enabled
PossibleIncorrectUsageOfAssignmentOperator Warning Always enabled
PossibleIncorrectUsageOfRedirectionOperator Warning Always enabled
ProvideCommentHelp Information Enabled Yes
ReservedCmdletChar Error Always enabled
ReservedParams Error Always enabled
ReviewUnusedParameter Warning Always enabled Yes
ShouldProcess Warning Always enabled
UseApprovedVerbs Warning Always enabled
UseBOMForUnicodeEncodedFile Warning Always enabled
UseCmdletCorrectly Warning Always enabled
UseCompatibleCmdlets Warning Always enabled Yes
UseCompatibleCommands Warning Disabled Yes
UseCompatibleSyntax Warning Disabled Yes
UseCompatibleTypes Warning Disabled Yes
UseConsistentIndentation Warning Disabled Yes
UseConsistentParameterSetName Warning Disabled Yes
UseConsistentParametersKind Warning Disabled Yes
UseConsistentWhitespace Warning Disabled Yes
UseConstrainedLanguageMode Warning Disabled Yes
UseCorrectCasing Information Disabled Yes
UseDeclaredVarsMoreThanAssignments Warning Always enabled
UseLiteralInitializerForHashtable Warning Always enabled
UseOutputTypeCorrectly Information Always enabled
UseProcessBlockForPipelineCommand Warning Always enabled
UsePSCredentialType Warning Always enabled
UseShouldProcessForStateChangingFunctions Warning Always enabled
UseSingleValueFromPipelineParameter Warning Disabled Yes
UseSingularNouns Warning Enabled Yes
UseSupportsShouldProcess Warning Always enabled
UseToExportFieldsInManifest Warning Always enabled
UseUsingScopeModifierInNewRunspaces Warning Always enabled
UseUTF8EncodingForHelpFile Warning Always enabled