Skip to content

Files

Latest commit

 

History

History
105 lines (86 loc) · 1.71 KB

DSCUseIdenticalParametersForDSC.md

File metadata and controls

105 lines (86 loc) · 1.71 KB

Pattern: Use of mismatched parameter for DSC

Issue: -

Description

The Get-TargetResource, Test-TargetResource and Set-TargetResource functions of DSC Resource must have the same parameters.

How

Correct the parameters for the functions in DSC resource.

Example of incorrect code:

function Get-TargetResource
{
    [OutputType([Hashtable])]
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name,

        [String]
        $TargetResource
    )
    ...
}

function Set-TargetResource
{
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name
    )
    ...
}

function Test-TargetResource
{
    [OutputType([System.Boolean])]
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name
    )
    ...
}

Example of correct code:

function Get-TargetResource
{
    [OutputType([Hashtable])]
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name,

        [String]
        $TargetResource
    )
    ...
}

function Set-TargetResource
{
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name,

        [String]
        $TargetResource
    )
    ...
}

function Test-TargetResource
{
    [OutputType([System.Boolean])]
    param
    (
        [parameter(Mandatory = $true)]
        [String]
        $Name,

        [String]
        $TargetResource
    )
    ...
}

Further Reading