Skip to content

PSDSC/Service fails in WinPS but not PS #965

@ThomasNieto

Description

@ThomasNieto

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

The Windows PowerShell is not properly passing the properties to the cmdlet resulting in an validation error.

Win PS

There is some JSON mangling going on as if a trailing null gets added. {"Name:bits":null}

Writing to command STDIN: {"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
jsonInput={"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
Module: PSDesiredStateConfiguration, Name: Service, Property: {}

PS

jsonInput={"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name":"bits"}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
Module: PSDesiredStateConfiguration, Name: Service, Property: {"Name":"bits"}

See how Property is empty on WinPS but not PS.

Steps to reproduce

dsc --trace-level trace resource get -r PSDesiredStateConfiguration/Service -i (@{ Name = 'bits' } | ConvertTo-Json -Compress)

Found that the issue does NOT occur if you omit -Compress or have a multi-line JSON.

Expected behavior

Errors

Actual behavior

Works

Error details

2025-07-13T19:21:21.211208Z DEBUG dsc_lib::discovery::command_discovery: 811: Read 948 items into lookup table from "C:\\Users\\Thomas\\AppData\\Local\\dsc\\AdaptedResourcesLookupTable.json"
2025-07-13T19:21:21.211954Z DEBUG dsc_lib::configure::depends_on: 27: Getting resource invocation order
2025-07-13T19:21:21.212055Z DEBUG dsc_lib::configure::depends_on: 90: Resource invocation order: [Resource { resource_type: "Microsoft.Windows/WindowsPowerShell", name: "PSDesiredStateConfiguration/Service", depends_on: None, kind: None, properties: Some({"resources": Array [Object {"name": String("PSDesiredStateConfiguration/Service"), "type": String("PSDesiredStateConfiguration/Service"), "properties": Object {"Name:bits": Null}}]}), metadata: None }]
2025-07-13T19:21:21.212162Z DEBUG dsc_lib::configure: 818: Invoke property expressions
2025-07-13T19:21:21.212243Z TRACE dsc_lib::configure: 826: Invoke property expression for resources: [{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}]
2025-07-13T19:21:21.212320Z DEBUG dsc_lib::configure: 818: Invoke property expressions
2025-07-13T19:21:21.212397Z TRACE dsc_lib::configure: 826: Invoke property expression for name: "PSDesiredStateConfiguration/Service"
2025-07-13T19:21:21.212475Z DEBUG dsc_lib::parser: 48: Parsing statement: PSDesiredStateConfiguration/Service
2025-07-13T19:21:21.212574Z DEBUG dsc_lib::parser: 72: Parsing string literal: PSDesiredStateConfiguration/Service
2025-07-13T19:21:21.212656Z TRACE dsc_lib::configure: 826: Invoke property expression for type: "PSDesiredStateConfiguration/Service"
2025-07-13T19:21:21.212734Z DEBUG dsc_lib::parser: 48: Parsing statement: PSDesiredStateConfiguration/Service
2025-07-13T19:21:21.212815Z DEBUG dsc_lib::parser: 72: Parsing string literal: PSDesiredStateConfiguration/Service
2025-07-13T19:21:21.212894Z TRACE dsc_lib::configure: 826: Invoke property expression for properties: {"Name:bits":null}
2025-07-13T19:21:21.212971Z DEBUG dsc_lib::configure: 818: Invoke property expressions
2025-07-13T19:21:21.213048Z TRACE dsc_lib::configure: 826: Invoke property expression for Name:bits: null
2025-07-13T19:21:21.213147Z DEBUG dsc_lib::configure: 315: resource_type Microsoft.Windows/WindowsPowerShell
2025-07-13T19:21:21.213226Z TRACE dsc_lib::configure: 317: filter: {"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
2025-07-13T19:21:21.213307Z DEBUG dsc_lib::dscresources::dscresource: 218: Invoking get for 'Microsoft.Windows/WindowsPowerShell'
2025-07-13T19:21:21.213400Z DEBUG dsc_lib::dscresources::command_resource: 29: Invoking get for 'Microsoft.Windows/WindowsPowerShell'
2025-07-13T19:21:21.213478Z DEBUG dsc_lib::dscresources::command_resource: 775: Verify JSON for 'Microsoft.Windows/WindowsPowerShell'
2025-07-13T19:21:21.213569Z TRACE dsc_lib::dscresources::command_resource: 779: Validating against JSON: {"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
2025-07-13T19:21:21.213663Z TRACE dsc_lib::dscresources::command_resource: 432: Invoking validate on 'Microsoft.Windows/WindowsPowerShell' using '{"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}'
2025-07-13T19:21:21.213744Z DEBUG dsc_lib::dscresources::command_resource: 762: No input kind specified
2025-07-13T19:21:21.213823Z  INFO dsc_lib::dscresources::command_resource: 441: Invoking validate on 'Microsoft.Windows/WindowsPowerShell' using 'powershell'
2025-07-13T19:21:21.213902Z DEBUG dsc_lib::dscresources::command_resource: 699: Invoking command 'powershell' with args Some(["-NoLogo", "-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "$Input | ./psDscAdapter/powershell.resource.ps1 Validate"])
2025-07-13T19:21:21.374919Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 35980: PSVersion=5.1.26100.4652
2025-07-13T19:21:21.375260Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 35980: PSPath=C:\Windows\System32\WindowsPowerShell\v1.0
2025-07-13T19:21:21.375564Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 35980: PSModulePath=C:\Users\Thomas\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
2025-07-13T19:21:21.406002Z DEBUG dsc_lib::dscresources::command_resource: 660: Process 'powershell' id 35980 exited with code 0
2025-07-13T19:21:21.407127Z DEBUG dsc_lib::dscresources::command_resource: 758: Parsing input as stdin
2025-07-13T19:21:21.407300Z  INFO dsc_lib::dscresources::command_resource: 40: Invoking get 'Microsoft.Windows/WindowsPowerShell' using 'powershell'
2025-07-13T19:21:21.407499Z DEBUG dsc_lib::dscresources::command_resource: 699: Invoking command 'powershell' with args Some(["-NoLogo", "-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "$Input | ./psDscAdapter/powershell.resource.ps1 Get"])
2025-07-13T19:21:21.411809Z TRACE dsc_lib::dscresources::command_resource: 616: Writing to command STDIN: {"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
2025-07-13T19:21:21.561749Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PSVersion=5.1.26100.4652
2025-07-13T19:21:21.562042Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PSPath=C:\Windows\System32\WindowsPowerShell\v1.0
2025-07-13T19:21:21.562291Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PSModulePath=C:\Users\Thomas\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
2025-07-13T19:21:21.569028Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: jsonInput={"resources":[{"name":"PSDesiredStateConfiguration/Service","type":"PSDesiredStateConfiguration/Service","properties":{"Name:bits":null}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}
2025-07-13T19:21:21.751309Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: Reading from Get-DscResource cache file C:\Users\Thomas\AppData\Local\dsc\WindowsPSAdapterCache.json
2025-07-13T19:21:21.781934Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: Checking cache for stale PSModulePath
2025-07-13T19:21:21.801178Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PSModulePath diff ''
2025-07-13T19:21:21.801977Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: Checking cache for stale entries
2025-07-13T19:21:21.857215Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: OS version: Microsoft Windows NT 10.0.26100.0
2025-07-13T19:21:21.858202Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PowerShell version: 5.1.26100.4652
2025-07-13T19:21:21.860443Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: PSDesiredStateConfiguration module version: 1.1
2025-07-13T19:21:21.875156Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: DSC resource implementation: ScriptBased
2025-07-13T19:21:21.909606Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012: Module: PSDesiredStateConfiguration, Name: Service, Property: {}
2025-07-13T19:21:21.917888Z DEBUG dsc_lib::dscresources::command_resource: 902: PID 25012:

Message                     : Cannot validate argument on parameter 'Property'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
ParameterName               : Property
ParameterType               : System.Collections.Hashtable
TypeSpecified               : System.Collections.Hashtable
ErrorId                     : ParameterArgumentValidationError
Line                        : 372
Offset                      : 165
CommandInvocation           : System.Management.Automation.InvocationInfo
ErrorRecord                 : Cannot validate argument on parameter 'Property'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
WasThrownFromThrowStatement : False
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.Management.Automation.ValidationMetadataException: The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
                                 at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
                                 at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
TargetSite                  : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                                 at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087




2025-07-13T19:21:21.919367Z ERROR dsc_lib::dscresources::command_resource: 896: PID 25012: Exception: Cannot validate argument on parameter 'Property'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
2025-07-13T19:21:21.934307Z DEBUG dsc_lib::dscresources::command_resource: 660: Process 'powershell' id 25012 exited with code 1
2025-07-13T19:21:21.935379Z ERROR dsc::resource_command: 64: Command: Resource 'powershell' [exit code 1] manifest description: Error

Environment data

7.6-preview4

Version

3.2-preview2

Visuals

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions