This topic contains 4 replies, has 5 voices, and was last updated by
October 11, 2016 at 5:26 pm #55198ParticipantPoints: 0Rank: 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.
October 12, 2016 at 12:40 am #55223ParticipantPoints: 0Rank: Member
can you please share the relevant pieces of the class based resource that is throwing that error? That would help us investigate more.
May 5, 2017 at 7:04 am #70188ParticipantPoints: 1Rank: Member
Hi, were you able to identify the problem?
February 26, 2018 at 4:13 pm #94662ParticipantPoints: -19Rank: Member
I had this same error when using a pscustomobject as a parameter, i changed it to a hashtable and the error disappeared.
March 6, 2018 at 8:16 pm #95284ParticipantPoints: 0Rank: 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.