Skip to main content
powershell/PSDSCReturnCorrectTypesForDSCFunctions 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/PSDSCReturnCorrectTypesForDSCFunctions"] or by setting rules.powershell.PSDSCReturnCorrectTypesForDSCFunctions.severity = "warning" in .tally.toml.

Description

The functions in DSC resources have specific return objects. For non-class based resources:
  • Set-TargetResource must not return any value.
  • Test-TargetResource must return a boolean.
  • Get-TargetResource must return a hash table.
For class based resources:
  • Set must not return any value.
  • Test must return a boolean.
  • Get must return an instance of the DSC class.

How

Ensure that each function returns the correct type.

Example 1

Problematic code

Correct code

Example 2

Problematic code

Correct code

Source

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