@@ -14,16 +14,20 @@ execute a simple command during the **Set** operation.
1414
1515## Test whether the command would run
1616
17- The following snippet shows how you can use the resource with the [ dsc resource test] [ 01 ] command to check whether the command would run.
17+ The following snippet shows how you can use the resource with the [ dsc resource test] [ 00 ] command to check whether
18+ the command would run.
1819
1920> [ !NOTE]
2021> The ` dsc resource test ` command performs a synthetic test on this resource. ` Microsoft.DSC.Transitional/RunCommandOnSet ` doesn't have
21- > the ` test ` capability defined in the [ resource manifest] [ 02 ]
22+ > the ` test ` capability defined in the [ resource manifest] [ 01 ]
2223
2324``` powershell
2425$instance = @{
25- executable = "echo"
26- arguments = @("Configuration applied successfully")
26+ executable = "C:\Windows\system32\cmd.exe"
27+ arguments = @(
28+ '/C',
29+ 'echo Hello world'
30+ )
2731} | ConvertTo-Json
2832
2933dsc resource test --resource Microsoft.DSC.Transitional/RunCommandOnSet --input $instance
@@ -34,30 +38,26 @@ When testing the resource, DSC returns a result indicating the desired state:
3438``` yaml
3539desiredState :
3640 arguments :
37- - Configuration applied successfully
38- executable : echo
41+ - /C
42+ - echo Hello world
43+ executable : C:\Windows\system32\cmd.exe
3944actualState :
40- executable : echo
45+ executable : C:\Windows\system32\cmd.exe
4146 arguments :
42- - Configuration applied successfully
47+ - /C
48+ - echo Hello world
4349inDesiredState : true
4450differingProperties : []
4551` ` `
4652
47- The ` inDesiredState` field of the result object is set to `true`, indicating that the command would be executed during a **Set** operation.
53+ The ` inDesiredState` field always returns `true` because of [pretest][02] is supported.
54+ This means the command is always executed during the **Set** operation.
4855
4956# # Run the command
5057
5158To execute the command, use the [dsc resource set][03] command.
5259
5360` ` ` powershell
54- $instance = @{
55- executable = "C:\W indows\s ystem32\c md.exe"
56- arguments = @(
57- '/C',
58- 'echo Hello world'
59- )
60- } | ConvertTo-Json
6161dsc resource set --resource Microsoft.DSC.Transitional/RunCommandOnSet --input $instance
6262` ` `
6363
@@ -84,6 +84,7 @@ changedProperties: []
8484> If you want to capture the output, you should redirect it to a file.
8585
8686<!-- Link reference definitions -->
87- [01] : ../../../../../cli/resource/test.md
88- [02] : ../../../../../../schemas/resource/manifest/test.md
87+ [00] : ../../../../../cli/resource/test.md
88+ [01] : ../../../../../../schemas/resource/manifest/test.md
89+ [02] : ../../../../../../../reference/cli/resource/set.md
8990[03] : ../../../../../cli/resource/set.md
0 commit comments