Class-based PowerShell DSC Resources include hidden properties in dsc config
results
#157
Closed
3 tasks done
dsc config
results
#157
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:DSC/powershellgroup/powershellgroup.resource.ps1
Line 179 in 6b286f1
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.The text was updated successfully, but these errors were encountered: