Access Parameter in SetScript member of Script Resource in Desired State Config

Welcome Forums DSC (Desired State Configuration) Access Parameter in SetScript member of Script Resource in Desired State Config

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
4 years, 4 months ago.

  • Author
    Posts
  • #16183

    Participant
    Points: 0
    Rank: Member

    Hello,

    Desired State Configuration....

    I have been stuck in Script Resource where i need a Configuration Parameter to be used in member SetScript. Here is what i need to do....

    Configuration MyConfig

    {

    param($MyComputerName)

    Script MyScript

    {

    Write-Verbose "Computer Name is : $MyComputerName"
    }

    GetScript = {}

    TestScript = {}

    }

    while executing above configuration, we are getting null value in $MyComputerName in SetScript. here, are the commands that i have been used.

    MyConfig -MyComputerName localhost

    Start-DscConfiguration -Wait -Verbose -Path ./MyConfig

  • #16210

    Keymaster
    Points: 1
    Rank: Member

    So, I don't think your structure is right. Your Script item should contain ONLY a GetScript and TestScript section. But both of those are actually OUTSIDE your Script item. The Write-Verbose isn't in a legal location there.

  • #16214

    Participant
    Points: 0
    Rank: Member

    ohhh. Really Sorry..its a typo mistake

    The Correct is...

    Configuration MyConfig

    {

    param($MyComputerName)

    Script MyScript

    {

    SetScript = {
    Write-Verbose "Computer Name is : $MyComputerName"
    }

    GetScript = {}

    TestScript = {return $bool}

    }

The topic ‘Access Parameter in SetScript member of Script Resource in Desired State Config’ is closed to new replies.