Custom DSC resource not recognized

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Aaron Jensen Aaron Jensen 2 years, 3 months ago.

  • Author
    Posts
  • #18521
    Profile photo of mayuri naware
    mayuri naware
    Participant

    Hi,

    I tried creating the custom resource by following the blog using XDscResourceDesigner
    http://blogs.msdn.com/b/powershell/archive/2013/11/19/resource-designer-tool-a-walkthrough-writing-a-dsc-resource.aspx

    I am able to import the module but when I run the Get-DscResource then I am getting follwing error ::

    CheckResourceFound : The term 'AppPoolServiceAccount' is not recognized as the name of a Resource.
    At
    C:\windows\system32\windowspowershell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2264
    char:13
    + CheckResourceFound $name $resources
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound

    I have also checked the folder structure it is as below:

    C:\Program Files\Windows Powershell\Modules
    |
    |(Folder)
    |
    ResourceName.psd1(File)
    |(Folder)
    |
    |(Folder)
    |
    .psm1 (file)
    .schema.mof (file)

    Any Help is appreciated 🙂

  • #18522
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I think your original post might have contained angle brackets, which the forum software currently eats and tries to process as HTML. Here's what the folder structure should look like:

    C:\Program Files\WindowsPowerShell\Modules\ModuleName
                                                         \ModuleName.psd1
                                                         \DSCResources
                                                                      \ResourceModuleName
                                                                                         \ResourceModuleName.psm1
                                                                                         \ResourceModuleName.schema.mof
    

    ModuleName and ResourceModuleName can be anything you like, so long as they match up between the folders and files. The schema.mof file will typically assign a friendly name to your classes so people don't have to remember something like PSHOrg_cSmbShare.

  • #18523
    Profile photo of mayuri naware
    mayuri naware
    Participant

    Thanks for the reply ,

    The folder structure is same as that you mentioned but path to the Modules folder is C:\Program Files\WindowsPowerShell\Modules and this path is included in the PSModulePath.

  • #18529
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Whoops, you're right. I had "WindowsPowerShell" on the brain and wound up typing "Windows\PowerShell" 🙂 I'll fix the previous post.

  • #18530
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Also, check out the DSC Resource Kit modules – they exhibit the correct structure, and it might be easier to see it right on your own system.

  • #18534
    Profile photo of Aaron Jensen
    Aaron Jensen
    Participant

    I don't know what your module name is, but it looks like your resource is named AppPoolServiceAccount. So your directory structure should look like this:

    C:\Program Files
    + WindowsPowerShell
      + Modules
        + ModuleName
          * ModuleName.psm1
          + DSCResources
            + AppPoolServiceAccount
              * AppPoolServiceAccount.psm1
              * AppPoolServiceAccount.schema.mof
    

    Have you imported your resource in your configuration block?

    Import-DscResource -ModuleName 'ModuleName' -Name '*'   # I've never been able to import specific resources with Import-DscResource
    

    What is the name of your resource in its schema.mof file? If it isn't the same as in the file system, it won't load. I don't remember if it is the same error you're getting, though.

    [ClassVersion("1.0.0.0"), FriendlyName("AppPoolServiceAccount")]
    class AppPoolServiceAccount: OMI_BaseResource
    {
    ;
    

You must be logged in to reply to this topic.