Skip to content

Get-DscProperty: Add optional switch parameter IgnoreZeroEnumValue #150

Closed
dsccommunity/DscResource.Base
#34
@johlju

Description

@johlju

Problem description

When a calss-based DSC resource is built using the pattern that DscResource.Base provides it is an option to set the flag FeatureOptionalEnums which allows an optional DSC property to use an Enum type. The enum value 0 is then ignored and considered to be equivalent to parameter set to $null. The command Get-DscProperty does not handle this and will return a property with the value 0 as a property that is set. 0 means user did not provide a value using the previous mentioned pattern and should have been ignored or seen as a property that is not set.

Verbose logs

not available

How to reproduce

Call Get-DscProperty with a property with an enum type and the value set to 0.

Expected behavior

Possible to to tell the command to ignore the enums with a value of zero.

Current behavior

Command will always return the propetty even if it is set to zero.

Suggested solution

Add an optional property IgnoreZeroEnumValue that will check if the datatype is enum and then if the value is zero, it will be skipped/ignored the same way as the command skips/ignores null value properties.

Operating system the target node is running

n/a

PowerShell version and build the target node is running

n/a

Module version used

Latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue is an enhancement request.good first issueThe issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions