You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ScriptRuleDocumentation.md
+20-12Lines changed: 20 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
-
##Documentation for Customized Rules in PowerShell Scripts
2
-
PSScriptAnalyzer uses MEF(Managed Extensibility Framework) to import all rules defined in the assembly. It can also consume rules written in PowerShell scripts.
1
+
## Documentation for Customized Rules in PowerShell Scripts
2
+
3
+
PSScriptAnalyzer uses MEF(Managed Extensibility Framework) to import all rules defined in the assembly. It can also consume rules written in PowerShell scripts.
3
4
4
5
When calling Invoke-ScriptAnalyzer, users can specify custom rules using the parameter `CustomizedRulePath`.
5
6
6
7
The purpose of this documentation is to server as a basic guide on creating your own customized rules.
7
8
8
-
###Basics
9
+
### Basics
10
+
9
11
- Functions should have comment-based help. Make sure .DESCRIPTION field is there, as it will be consumed as rule description for the customized rule.
12
+
10
13
```PowerShell
11
14
<#
12
15
.SYNOPSIS
@@ -21,11 +24,13 @@ The purpose of this documentation is to server as a basic guide on creating your
- Make sure you export the function(s) at the end of the script using Export-ModuleMember
56
+
50
57
```PowerShell
51
58
Export-ModuleMember -Function (FunctionName)
52
59
```
53
60
54
-
###Example
61
+
### Example
62
+
55
63
```PowerShell
56
64
<#
57
65
.SYNOPSIS
58
66
Uses #Requires -RunAsAdministrator instead of your own methods.
59
67
.DESCRIPTION
60
-
The #Requires statement prevents a script from running unless the Windows PowerShell version, modules, snap-ins, and module and snap-in version prerequisites are met.
61
-
From Windows PowerShell 4.0, the #Requires statement let script developers require that sessions be run with elevated user rights (run as Administrator).
68
+
The #Requires statement prevents a script from running unless the Windows PowerShell version, modules, snap-ins, and module and snap-in version prerequisites are met.
69
+
From Windows PowerShell 4.0, the #Requires statement let script developers require that sessions be run with elevated user rights (run as Administrator).
62
70
Script developers does not need to write their own methods any more.
63
71
To fix a violation of this rule, please consider to use #Requires -RunAsAdministrator instead of your own methods.
64
72
.EXAMPLE
@@ -123,12 +131,12 @@ function Measure-RequiresRunAsAdministrator
0 commit comments