DSC Class based resource error

Welcome Forums DSC (Desired State Configuration) DSC Class based resource error

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

 
Participant
8 months, 1 week ago.

  • Author
    Posts
  • #55198

    Participant
    Points: 0
    Rank: Member

    Hi, I am looking around to see if anyone else has seen this error when creating DSC class-based resources.
    I have a few resources in the same psm1 file. The first couple of resources work normally and I haven't done anything different in the next resource I am trying to create.

    My resource shows up with Get-DscResource properly. However, when I run an Invoke-DscResource -Method Test on it I get an error:
    Invoke-DscResource : All classes must have a reference to ConfigurationResource.

    My searches don't show me anything and I just simply don't see that I have done anything different from any other class-based resource I have create.

    Thanks

  • #55223

    Participant
    Points: 0
    Rank: Member

    can you please share the relevant pieces of the class based resource that is throwing that error? That would help us investigate more.

  • #70188

    Participant
    Points: 0
    Rank: Member

    Hi, were you able to identify the problem?

  • #94662

    Participant
    Points: -19
    Rank: Member

    I had this same error when using a pscustomobject as a parameter, i changed it to a hashtable and the error disappeared.

    • #95284

      Participant
      Points: 0
      Rank: Member

      Thanks, @matt2005. Your response pointed me to my solution.

      My anomaly was that it was that the DSC successfully applied on my development machine (it's just a desktop wallpaper, so I was developing live). However, didn't work on any of my production test machines. Both systems are running Win10. However, my development system is running 1709 (PSVersion: 5.1.16299.248); production test systems are 1703 (PSVersion: 5.1.15063.786).

      I had a parameter that was an ArrayList ([System.Collections.ArrayList]) because I was using a dynamic array size. Instead I changed it to [string[]] and it worked fine. I just had to use the following logic to account for the fixed size:

      $this.StaticSizedArray = $this.StaticSizedArray + @('Test')

      Hope this helps others.

The topic ‘DSC Class based resource error’ is closed to new replies.