KeyProperty : Repro Example (PSDSC)
NormalProperty : Should be in results data.
NonDscProperty : This property shouldn't be in results data, because it's not a DSC property.
KeyProperty : Repro Example (DSCv3)
NormalProperty : Should be in results data.
NonDscProperty : This property shouldn't be in results data, because it's not a DSC property.
HiddenNonDscProperty : This property shouldn't be in results data, because it's hidden and not a DSC property.
HiddenDscProperty : This property should be in results data, but is an anti-pattern.
Compare the actual and preferred output statuses, with metadata:
KeyProperty : Repro Example
NormalProperty : Should be in results data.
NonDscProperty : This property shouldn't be in results data, because it's not a DSC property.
KeyProperty : Repro Example
NormalProperty : Should be in results data.
NonDscProperty : This property shouldn't be in results data, because it's not a DSC property.
HiddenNonDscProperty : This property shouldn't be in results data, because it's hidden and not a DSC property.
HiddenDscProperty : This property should be in results data, but is an anti-pattern.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
DSC (build from main), PSDSC v2.0.7
Visuals
No response
Notes
While both PSDSC and DSCv3 do show the NonDscProperty in the results, that seems like a bug in PSDesiredStateConfiguration. Similarly, the non-inclusion of StaticDscProperty is (arguably) a bug in PSDesiredStateConfiguration.
However, the return data handling by the DSC/PowerShellGroup resource provider is to just convert the result data to JSON:
This runs into PowerShell/PowerShell#9847, where the serialization unexpectedly includes hidden properties (compared to ConvertTo-Csv and Select-Object).
Fix Proposal
Filter the returned properties to only include properties with the DscProperty attribute, so that the schema surface for the resources matches with Get-DscResource and the contract that the class definition implements.
Prerequisites
Steps to reproduce
Create the files for a new PowerShell module
Define the module manifest:
Define the root module script:
Add the folder containing the repro module to the
PSModulePath
:Confirm you can get the
ReproResultData
dsc resource and see its properties:Invoke the resource with
Invoke-DscResource
Invoke the resource with
dsc resource
:Compare the actual and preferred output statuses, with metadata:
Expected behavior
Actual behavior
Error details
No response
Environment data
Version
DSC (build from main), PSDSC v2.0.7
Visuals
No response
Notes
While both PSDSC and DSCv3 do show the NonDscProperty in the results, that seems like a bug in PSDesiredStateConfiguration. Similarly, the non-inclusion of StaticDscProperty is (arguably) a bug in PSDesiredStateConfiguration.
However, the return data handling by the
DSC/PowerShellGroup
resource provider is to just convert the result data to JSON:https://github.com/PowerShell/DSC/blob/6b286f190c81f2652cfe1fbbbfe10474467eece5/powershellgroup/powershellgroup.resource.ps1#L179
This runs into PowerShell/PowerShell#9847, where the serialization unexpectedly includes hidden properties (compared to
ConvertTo-Csv
andSelect-Object
).Fix Proposal
Filter the returned properties to only include properties with the DscProperty attribute, so that the schema surface for the resources matches with
Get-DscResource
and the contract that the class definition implements.