Skip to main content
powershell/PSDSCUseIdenticalMandatoryParametersForDSC is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
tally disables this rule by default because Desired State Configuration resources are out of scope for Dockerfile RUN analysis. Re-enable it with include = ["powershell/PSDSCUseIdenticalMandatoryParametersForDSC"] or by setting rules.powershell.PSDSCUseIdenticalMandatoryParametersForDSC.severity = "warning" in .tally.toml.

Description

For script-based DSC resources, if a property is declared with attributes Key or Required in a MOF file, then it should be present as a mandatory parameter in the corresponding Get-TargetResource, Set-TargetResource and Test-TargetResource functions.

How

Make sure all the properties with Key or Required attributes have equivalent mandatory parameters in the Get/Set/Test functions.

Examples

Consider the following mof file.

Problematic code

Correct code

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for DSCUseIdenticalMandatoryParametersForDSC, licensed under CC BY 4.0.