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
Make sure you are able to repro it on the latest version
Search the existing issues.
Summary
I am trying to run a command using Microsoft.DSC.Transitional/RunCommandOnSet.
It only has an effect when calling the resource via '{json input}' | dsc resource set -r Microsoft.DSC.Transactional/RunCommandOnSet -f -.
From within a configuration document though, it doesn't do anything.
Steps to reproduce
Configuration document:
# example.dsc.config.yaml$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.jsonresources:
- name: one more linetype: Microsoft.DSC.Transitional/RunCommandOnSetproperties:
executable: pwsharguments:
- -Command
- "Write-Output Hello | Out-File example.txt -Append"
Run it: dsc config set -f example.dsc.config.yaml
Expected behavior
example.txt should get created (next to dsc.exe) and have content Hello.
❌Look for example.txt it should get created next to dsc.exe but it is nowhere to be found.
Error details
I have run dsc -l trace config set -f example.dsc.config.yaml to grab the generated json input: {"executable":"pwsh","arguments":["-Command","Write-Output Hello | Out-File example.txt -Append"]}
I go and run the resource direcly based on the example (
And it works perfectly, example.txt gets created and each time I run the above, one more line gets appended.
👉 My wild guess is that dsc config does not invoke set on the resource because it deems the resource in desired state. Reading #302 and #321, this might be due to the synthetic noop test (or get?) for the resource. I might be totally wrong, though.
Full trace:
dsc -l trace config set -f .\run-command-example.dsc.config.yaml
2025-02-23T16:19:40.770966Z INFO dsc::util: 417: Trace-level is Trace
2025-02-23T16:19:40.771272Z DEBUG dsc: 42: Running DSC version: 3.0.0-rc.1
2025-02-23T16:19:40.771514Z DEBUG dsc::util: 554: Setting DSC_CONFIG_ROOT env var as 'C:\Users\david\devp\myconfig\dscv3'
2025-02-23T16:19:40.771727Z TRACE dsc::util: 454: Input: None, File: Some("C:\\Users\\david\\devp\\myconfig\\dscv3\\run-command-example.dsc.config.yaml")
2025-02-23T16:19:40.771930Z DEBUG dsc::util: 465: Reading input from file C:\Users\david\devp\myconfig\dscv3\run-command-example.dsc.config.yaml
2025-02-23T16:19:40.772391Z DEBUG dsc_lib::discovery::command_discovery: 392: Searching for resources: ["Microsoft.DSC.Transitional/RunCommandOnSet"]
2025-02-23T16:19:40.772843Z INFO dsc_lib::discovery::command_discovery: 173: Discovering resources using filter: *
2025-02-23T16:19:40.773085Z DEBUG dsc_lib::discovery::command_discovery: 176: Using regex ^.*?$ as filter for adapter name
2025-02-23T16:19:40.773730Z DEBUG dsc_lib::util: 188: Found setting 'resourcePath' in c:\Users\david\bin\DSCv3\dsc_default.settings.json
2025-02-23T16:19:40.774509Z DEBUG dsc_lib::util: 198: Found setting 'resourcePath' in c:\Users\david\bin\DSCv3\dsc.settings.json
2025-02-23T16:19:40.774994Z DEBUG dsc_lib::util: 212: Setting 'resourcePath' not found in C:\ProgramData\dsc\dsc.settings.json
2025-02-23T16:19:40.775371Z DEBUG dsc_lib::discovery::command_discovery: 122: Appending PATH to resourcePath
2025-02-23T16:19:40.775667Z TRACE dsc_lib::discovery::command_discovery: 125: Original PATH: **************
2025-02-23T16:19:40.776804Z TRACE dsc_lib::discovery::command_discovery: 144: Exe home is already in path: c:\Users\david\bin\DSCv3
2025-02-23T16:19:40.777166Z DEBUG dsc_lib::discovery::command_discovery: 157: Using Resource Path: *************
2025-02-23T16:19:40.778173Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: C:\Users\david\bin\DSCv3_extras\include.dsc.resource.json
2025-02-23T16:19:40.778724Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.DSC/Include' found
2025-02-23T16:19:40.871375Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\assertion.dsc.resource.json
2025-02-23T16:19:40.872068Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.DSC/Assertion' found
2025-02-23T16:19:40.872545Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\echo.dsc.resource.json
2025-02-23T16:19:40.873055Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.DSC.Debug/Echo' found
2025-02-23T16:19:40.873382Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\group.dsc.resource.json
2025-02-23T16:19:40.873728Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.DSC/Group' found
2025-02-23T16:19:40.874050Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\osinfo.dsc.resource.json
2025-02-23T16:19:40.874480Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft/OSInfo' found
2025-02-23T16:19:40.875026Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\powershell.dsc.resource.json
2025-02-23T16:19:40.875502Z TRACE dsc_lib::discovery::command_discovery: 230: Resource adapter 'Microsoft.DSC/PowerShell' found
2025-02-23T16:19:40.875907Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\reboot_pending.dsc.resource.json
2025-02-23T16:19:40.876233Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.Windows/RebootPending' found
2025-02-23T16:19:40.876565Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\registry.dsc.resource.json
2025-02-23T16:19:40.876898Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.Windows/Registry' found
2025-02-23T16:19:40.877299Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\RunCommandOnSet.dsc.resource.json
2025-02-23T16:19:40.877644Z TRACE dsc_lib::discovery::command_discovery: 233: Resource 'Microsoft.DSC.Transitional/RunCommandOnSet' found
2025-02-23T16:19:40.878004Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\windowspowershell.dsc.resource.json
2025-02-23T16:19:40.878339Z TRACE dsc_lib::discovery::command_discovery: 230: Resource adapter 'Microsoft.Windows/WindowsPowerShell' found
2025-02-23T16:19:40.878656Z TRACE dsc_lib::discovery::command_discovery: 212: Found resource manifest: c:\Users\david\bin\DSCv3\wmi.dsc.resource.json
2025-02-23T16:19:40.878948Z TRACE dsc_lib::discovery::command_discovery: 230: Resource adapter 'Microsoft.Windows/WMI' found
2025-02-23T16:19:40.879389Z DEBUG dsc_lib::discovery::command_discovery: 244: Found 8 matching non-adapter-based resources
2025-02-23T16:19:40.879895Z DEBUG dsc::subcommand: 313: No parameters specified
2025-02-23T16:19:40.880063Z INFO dsc_lib::configure: 553: No parameters defined in configuration and no parameters input
2025-02-23T16:19:40.880218Z DEBUG dsc_lib::configure: 621: No variables defined in configuration
2025-02-23T16:19:40.880335Z DEBUG dsc_lib::configure::depends_on: 27: Getting resource invocation order
2025-02-23T16:19:40.880454Z DEBUG dsc_lib::configure::depends_on: 90: Resource invocation order: [Resource { resource_type: "Microsoft.DSC.Transitional/RunCommandOnSet", name: "one more line", depends_on: None, properties: Some({"executable": String("pwsh"), "arguments": Array [String("-Command"), String("Write-Output Hello | Out-File example.txt -Append")]}), metadata: None }]
2025-02-23T16:19:40.880963Z DEBUG dsc_lib::configure: 700: Invoke property expressions
2025-02-23T16:19:40.881457Z TRACE dsc_lib::configure: 708: Invoke property expression for executable: "pwsh"
2025-02-23T16:19:40.881822Z DEBUG dsc_lib::parser: 48: Parsing statement: pwsh
2025-02-23T16:19:40.885186Z DEBUG dsc_lib::dscresources::command_resource: 738: Verify JSON for 'Microsoft.DSC.Transitional/RunCommandOnSet'
2025-02-23T16:19:40.889314Z INFO dsc_lib::dscresources::command_resource: 103: No pretest, invoking test on 'Microsoft.DSC.Transitional/RunCommandOnSet'
2025-02-23T16:19:40.889654Z DEBUG dsc_lib::dscresources::command_resource: 252: Invoking test for 'Microsoft.DSC.Transitional/RunCommandOnSet'
2025-02-23T16:19:40.889919Z INFO dsc_lib::dscresources::command_resource: 254: Resource 'Microsoft.DSC.Transitional/RunCommandOnSet' does not implement test, performing synthetic test
2025-02-23T16:19:40.890155Z DEBUG dsc_lib::dscresources::command_resource: 29: Invoking get for 'Microsoft.DSC.Transitional/RunCommandOnSet'
2025-02-23T16:19:40.890382Z DEBUG dsc_lib::dscresources::command_resource: 738: Verify JSON for 'Microsoft.DSC.Transitional/RunCommandOnSet'
2025-02-23T16:19:40.890668Z DEBUG dsc_lib::dscresources::command_resource: 721: Parsing input as stdin
2025-02-23T16:19:40.890869Z INFO dsc_lib::dscresources::command_resource: 40: Invoking get 'Microsoft.DSC.Transitional/RunCommandOnSet' using 'runcommandonset'
2025-02-23T16:19:40.891095Z DEBUG dsc_lib::dscresources::command_resource: 672: Invoking command 'runcommandonset' with args Some(["--trace-format", "json", "get"])
2025-02-23T16:19:40.895004Z TRACE dsc_lib::dscresources::command_resource: 589: Writing to command STDIN: {"executable":"pwsh","arguments":["-Command","Write-Output Hello | Out-File example.txt -Append"]}
2025-02-23T16:19:40.899242Z WARN dsc_lib::dscresources::command_resource: 844: trace_message="PID 99968: This resource is not idempotent"
2025-02-23T16:19:40.900850Z DEBUG dsc_lib::dscresources::command_resource: 633: Process 'runcommandonset' id 99968 exited with code 0
Environment data
Name Value
---------
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
dsc 3.0.0-rc.1
Visuals
No response
The text was updated successfully, but these errors were encountered:
@tgauth can you investigate? The fix might simply be to declare in the resource manifest that pretest is implemented so that dsc doesn't perform a get and believe it's in desired state and skip set
Prerequisites
Summary
I am trying to run a command using
Microsoft.DSC.Transitional/RunCommandOnSet
.It only has an effect when calling the resource via
'{json input}' | dsc resource set -r Microsoft.DSC.Transactional/RunCommandOnSet -f -
.From within a configuration document though, it doesn't do anything.
Steps to reproduce
Run it:
dsc config set -f example.dsc.config.yaml
Expected behavior
example.txt should get created (next to dsc.exe) and have content Hello.
Actual behavior
Output:
❌Look for example.txt it should get created next to dsc.exe but it is nowhere to be found.
Error details
I have run
dsc -l trace config set -f example.dsc.config.yaml
to grab the generated json input:{"executable":"pwsh","arguments":["-Command","Write-Output Hello | Out-File example.txt -Append"]}
I go and run the resource direcly based on the example (
DSC/runcommandonset/tests/runcommandonset.set.tests.ps1
Lines 20 to 30 in 8c290aa
And it works perfectly, example.txt gets created and each time I run the above, one more line gets appended.
👉 My wild guess is that
dsc config
does not invokeset
on the resource because it deems the resource in desired state. Reading #302 and #321, this might be due to the synthetic noop test (or get?) for the resource. I might be totally wrong, though.Full trace:
Environment data
Version
dsc 3.0.0-rc.1
Visuals
No response
The text was updated successfully, but these errors were encountered: