How to use PS cmdlets in a DSC resource helper functions?

This topic contains 3 replies, has 2 voices, and was last updated by  Janis Berzins 1 year, 10 months ago.

  • Author
    Posts
  • #32569

    Janis Berzins
    Participant

    I have created a DSC module that has few helper functions in it. I would like to use a cmdlet in one of the helper functions from a PS module in one of the helper functions that I have included in DSC module.

    In my tests the helper function was unable to execute the cmdlet as it was not recognized. Obviously the PS module should be imported before running cmdlet in the DSC's module helper function.

    So is it possible to create some sort of dependence for DSC module that would import PS module that contains this cmdlet?

  • #32570

    Don Jones
    Keymaster

    So:

    DSC module has Helper Functions.

    Helper Functions need to use a command that lives in a normal Module.

    Is the Module correctly stored in one of the paths in your PSModulePath environment variable? If not, the Module will need to be loaded ahead of time. Would it be possible to simply put the Module into one of the correct paths?

  • #32620

    Janis Berzins
    Participant

    The module is in the correct location.
    How would I load the normal module ahead when DSC module runs and runs the normal command that's in the normal module?

    Do I run the import-module cmdlet in DSC's module helper function?

  • #32623

    Janis Berzins
    Participant

    Sorted by running import-module when calling the helper function.

You must be logged in to reply to this topic.