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
This is a considerable commit, based up a considerable about of work.
The following things should now, hopefully, be in the documentation:
1. Code blocks correctly marked as PowerShell or C# to ensure GitHub provides the right syntax highlighting.
2. Descriptions, How to Fix statements and Examples should correctly refect the check.
3. Examples have been expanded and improved. Examples now in the majority of cases follow the best practices.
Outstanding issues:
1. DSC rules need more clarity if they apply to class/non-class based resources.
2. AvoidShouldContinueWithoutForce needs more clarity. I couldn't fully get my head around some of the what and why.
Copy file name to clipboardExpand all lines: PowerShellBestPractices.md
+9-13Lines changed: 9 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ The following guidelines come from a combined effort from both the PowerShell te
5
5
6
6
##Cmdlet Design Rules
7
7
###Severity: Error
8
+
8
9
###Severity: Warning
9
10
- Use Only Approved Verbs [UseApprovedVerbs](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/UseApprovedVerbs.md)
10
11
- Cmdlets Names: Characters that cannot be Used [AvoidReservedCharInCmdlet](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/AvoidReservedCharInCmdlet.md)
@@ -65,8 +66,6 @@ The following guidelines come from a combined effort from both the PowerShell te
65
66
- Copy $Error[0] to your own variable
66
67
- Avoid using pipelines in scripts
67
68
- If a return type is declared, the cmdlet must return that type. If a type is returned, a return type must be declared.
68
-
69
-
70
69
71
70
##Scripting Style
72
71
###Severity: Error
@@ -101,7 +100,6 @@ The following guidelines come from a combined effort from both the PowerShell te
101
100
###Severity: TBD
102
101
- APIKey and Credentials variables that are initialized (information disclosure)
103
102
104
-
105
103
##DSC Related Rules
106
104
###Severity: Error
107
105
- Use standard DSC methods [UseStandardDSCFunctionsInResource](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/UseStandardDSC FunctionsInResource.md)
@@ -112,9 +110,9 @@ The following guidelines come from a combined effort from both the PowerShell te
112
110
113
111
###Severity: Information
114
112
- All of the following three rule are grouped by: [ReturnCorrectTypeDSCFunctions](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/ReturnCorrectTypeDSCFunctions.md)
115
-
- Avoid return any object from a Set-TargetResource function
116
-
- Returning a Boolean object from a Test-TargetResource function
117
-
- Returning an object from a Get-TargetResource function
113
+
- Avoid return any object from a Set-TargetResource or Set (Class Based) function
114
+
- Returning a Boolean object from a Test-TargetResource or Test (Class Based) function
115
+
- Returning an object from a Get-TargetResource or Get (Class Based) function
118
116
- DSC resources should have DSC tests [DSCTestsPresent](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/DscTestsPresent.md)
119
117
- DSC resources should have DSC examples [DSCExamplesPresent](https://github.com/PowerShell/PSScriptAnalyzer/blob/master/RuleDocumentation/DscExamplesPresent.md)
120
118
@@ -125,11 +123,9 @@ The following guidelines come from a combined effort from both the PowerShell te
125
123
- Use ShouldProcess for a Set DSC method
126
124
- Resource module contains DscResources folder which contains the resources [IssueOpened](https://github.com/PowerShell/PSScriptAnalyzer/issues/130)
127
125
128
-
129
-
130
126
###Reference:
131
-
* Cmdlet Development Guidelines from MSDN site (Cmdlet Development Guidelines)
132
-
133
-
*The Community Book of PowerShell Practices (Compiled by Don Jones and Matt Penny and the Windows PowerShell Community)
134
-
135
-
*[PowerShell DSC Resource Design and Testing Checklist](http://blogs.msdn.com/b/powershell/archive/2014/11/18/powershell-dsc-resource-design-and-testing-checklist.aspx)
127
+
* Cmdlet Development Guidelines from MSDN site (Cmdlet Development Guidelines): https://msdn.microsoft.com/en-us/library/ms714657(v=vs.85).aspx
128
+
* The Community Book of PowerShell Practices (Compiled by Don Jones and Matt Penny and the Windows PowerShell Community): https://powershell.org/community-book-of-powershell-practices/
129
+
* PowerShell DSC Resource Design and Testing Checklist: http://blogs.msdn.com/b/powershell/archive/2014/11/18/powershell-dsc-resource-design-and-testing-checklist.aspx
130
+
* DSC Guidelines can also be found in the DSC Resources Repository: https://github.com/PowerShell/DscResources
131
+
*The Unofficial PowerShell Best Practices and Style Guide: https://github.com/PoshCode/PowerShellPracticeAndStyle
0 commit comments