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: RuleDocumentation/UseIdenticalMandatoryParametersForDSC.md
+53-20Lines changed: 53 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,20 @@
4
4
5
5
## Description
6
6
7
-
For script based DSC resources the `Get-TargetResource`, `Test-TargetResource` and `Set-TargetResource` functions must have identical mandatory parameters that are also the keys in the corresponding `mof` file.
7
+
For script based DSC resources the `Get-TargetResource`, `Test-TargetResource` and `Set-TargetResource` functions:
8
+
9
+
1. If a parameter is declared as `mandatory` in any of the `Get/Set/Test` functions, then it should be a mandatory parameter in all the three functions.
10
+
1. If a property is declared with attributes `Key` of `Required` in a mof file, then is should be present as a mandatory parameter in the `Get/Set/Test` functions of the corresponding resource file.
8
11
9
12
## How
10
13
11
-
Make sure all the keys have equivalent mandatory parameters in the `Get/Set/Test` functions.
14
+
1. Make sure `Get/Set/Test` declare identical mandatory parameters.
15
+
1. Make sure all the properties with `Key` and `Required` attributes have equivalent mandatory parameters in the `Get/Set/Test` functions.
12
16
13
17
## Example
18
+
14
19
Consider the following `mof` file.
20
+
15
21
```powershell
16
22
class WaitForAny : OMI_BaseResource
17
23
{
@@ -28,37 +34,48 @@ class WaitForAny : OMI_BaseResource
0 commit comments