Get-ScriptAnalyzerRule

Get-ScriptAnalyzerRule

Gets rules that are used by Windows PowerShell ScriptAnalyzer.

구문

Parameter Set: Default
Get-ScriptAnalyzerRule [-CustomizedRulePath <String[]> ] [-Name <String[]> ] [-Severity <String[]> ] [ <CommonParameters>]

자세한 설명

Get-ScriptAnalyzerRule gets a list of all rules that work with the PSScriptAnalyzer module, and against which scripts are evaluated when you run the Invoke-ScriptAnalyzer cmdlet. Each rule has the following properties: Name, CommonName, Description, Severity, SourceType, and SourceName. CommonName is the display name of the rule. Use the value of the Name property when you want to include or exclude a rule in script analysis. The value of the Description property explains what in scripts might violate rules, and provides suggestions for improving your script.

매개 변수

-CustomizedRulePath<String[]>

Path to a customized or user-created module or assembly of rules.

별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 허용 여부

false

와일드카드 문자 허용 여부

false

-Name<String[]>

The names of one or more rules. The value of this parameter is taken from the Name property of a rule. Separate multiple names with commas.

별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 허용 여부

false

와일드카드 문자 허용 여부

true

-Severity<String[]>

If you add this parameter, only results that match the specified severity levels are displayed. Valid values for this parameter are Warning, Error, and Strict. Separate multiple severity levels with commas.

별칭

없음

필수 여부

false

위치

named

기본값

없음

파이프라인 입력 허용 여부

false

와일드카드 문자 허용 여부

false

<CommonParameters>

이 cmdlet은 -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable 등의 일반 매개 변수를 지원합니다. 자세한 내용은 TechNet의 about_CommonParameters(https://go.microsoft.com/fwlink/p/?LinkID=113216)

입력

입력 형식은 cmdlet으로 파이프할 수 있는 개체의 형식입니다.

출력

출력 형식은 cmdlet 실행 시 출력되는 개체의 형식입니다.

  • Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.RuleInfo

-------------------------- EXAMPLE 1 --------------------------

Running Get-ScriptAnalyzerRule with no parameters returns all built-in Windows PowerShell rules.

PS C:\>Get-ScriptAnalyzerRule

-------------------------- EXAMPLE 2 --------------------------

This example returns the PSAvoidUsingcmdletaliases and PSReservedCmdletChar rules.

PS C:\>Get-ScriptAnalyzerRule -Name PSAvoidUsingcmdletaliases, PSReservedCmdletChar

-------------------------- EXAMPLE 3 --------------------------

This example gets rules with names that start with the string, PSAvoid. Note that the Name parameter accepts wildcard characters.

PS C:\>Get-ScriptAnalyzerRule -Name PSAvoid*

-------------------------- EXAMPLE 4 --------------------------

This example adds the Severity parameter to get rules that have the specified severity levels.

PS C:\>Get-ScriptAnalyzerRule -Severity Information, Error

-------------------------- EXAMPLE 5 --------------------------

This example returns rules that have been customized or created by Windows PowerShell users. You add the CustomizedRulePath parameter to specify a path to where custom (not the built-in Windows PowerShell rules) are stored. In this example, the rules are stored in the CommunityRules folder on the D:\ drive.

PS C:\>Get-ScriptAnalyzerRule -CustomizedRulePath D:\CommunityRules

관련 항목

Invoke-ScriptAnalyzer