June 19, 2014 at 7:15 am #16363
So, I have been working on a Custom Resource for a while now and when I finally went to test it in a Configuration, I come to find out that Get-DSCResource does not recognize it as a resource. The path to the resource is C:\Program Files\WindowsPowerShell\Modules\DSCResources\cSCVMM. No matter what I have tried, I cannot get Get-DSCResource to find it/recognize it/load it.
Thinking I screwed something up, I just copied and pasted the example resource in this article (http://blogs.msdn.com/b/powershell/archive/2013/11/19/resource-designer-tool-a-walkthrough-writing-a-dsc-resource.aspx) and I have the same problem.
I have tested this on WMF 4.0, WMF 5.0 Preview, Windows 8.1 and Server 2012 R2. I should also mention that when I run Test-xDSCSchema against the .MOF in either resource it returns true. Additionally I can load the module for my Custom Resource without any issue as well.
Please tell me I am just missing something completely obvious?
June 19, 2014 at 7:24 am #16366
Wrong folder structure.
_modulename_ has to be a real module with at least a .PSD1. E.g., xNetworking.
_resourcename_ is the actual resource, and must contain a .PSM1, the schema MOF, and usually a .PSD1. E.g., xIPAddress.
You can't just have a \DSCResources under \Modules.
June 19, 2014 at 7:45 am #16367
That sure enough did the trick. It looks my problem was that when I created the Resource I did this:
New-xDscResource -Name cSCVMM_Hardware -Property $DVDDrive, $VMNetwork, $CPUCount, $Ensure, $Name, $VMMServer -FriendlyName "SCVMM_Hardware" -ClassVersion 1.0 -Path 'C:\Program Files\WindowsPowerShell\Modules\'
This just created a DSCResources folder, and then put everything underneath of it, which caused me to be off a whole level. I should have done it this way:
New-xDscResource -Name cSCVMM_Hardware -Property $DVDDrive, $VMNetwork, $CPUCount, $Ensure, $Name, $VMMServer -FriendlyName "SCVMM_Hardware" -ClassVersion 1.0 -Path 'C:\Program Files\WindowsPowerShell\Modules\cSCVMM'
Lesson learned! Thank you!
You must be logged in to reply to this topic.