DSC config in PowerShell module?

This topic contains 4 replies, has 2 voices, and was last updated by  Mike 1 month ago.

  • Author
    Posts
  • #99598

    Mike
    Participant

    Hi All,

    Sorry in advance if I should've put this in the DSC section. Wasn't 100% sure if the proper place was there or this sub section.

    Just about ready to publish my first PowerShell module to PowerShell Gallery. My code is 4-5 scripts for building a clustered Hyper-V environment. One of the scripts is a DSC config. My question is, can I put the DSC config inside the module? My 4-5 scripts are functions and I'll be saving them in one .psm1 file. Inside there I'd need to put my DSC config. Is this possible without getting my module declined from PowerShell Gallery?

  • #99601

    Will Anderson
    Keymaster

    Hey there Mike,

    You can create a composite resource and have it in the same module as your PowerShell commands. Are you talking about doing that?

  • #99604

    Mike
    Participant

    Will,

    Not exactly (unless I haven't done enough research on composite resources). Essentially I want my DSC config to be in my module like a function of a cmdlet. When someone installs my module and runs Get-Command -Module MyModule, I want the DSC config to be listed there as.. not sure what it would be listed as, because it's not a function. It's a combined project, so I'd prefer not to separate it because to build the full environment, the DSC config is needed.

  • #99610

    Will Anderson
    Keymaster

    Hi there Mike,

    A DSC Resource would not be listed as a command in the module, nor would it be called in as a function. You could conceivably add it into the same module, but you'd still have to call the configuration, compile the mof, and run the configuration. I'd say going about it that way would likely get it rejected, but I'm not sure. The best way would be for you to add it as a composite resource by taking out the node "localhost" references, putting it into a DSC Resources folder inside the module, and adding a manifest. Then you'd be likely to pass, and it would be more easily readable from a use perspective.

  • #99615

    Mike
    Participant

    Will,

    Got it. So you're pretty much saying the folder that holds my .psm1 and .psd1 will have a sub-folder inside with my DSC composite resource and the .psd1 along with it?

You must be logged in to reply to this topic.