How to use custom cmdlets in a custom dsc resource

So the title says it all really. I wan’t to write a custom resource and within it use cmdlets that are not going to be available on the target machine by default.

I am not really sure how I can get DSC to install this resource on the target box before running the resources. I have tried wrapping it up in the same way as my custom dsc resources and making them available on the pull server, then adding a:

Import-DscResource -ModuleName “CmdletModule”

Just under where I import my custom dsc resources. This does not seem to pull these resources on to the target box. Anyone got any ideas?

The pull server can only be used to deploy DSC resource modules. The LCM won’t look for dependencies there.

You have some choices. You could use the File resource to copy your dependent module to the target, and make any of your custom resources dependent on that, so your custom stuff won’t try to run until the copy is complete.

Depending on what this other module is, you could also roll it into your DSC resource and make it a part of it.

When you create your custom resource you could add your code as helper functions.

One of my DSC Resources looks like this:

function Get-TargetResource {}
function Set-TargetResource {}
function Test-TargetResource {}
function New-Answerfile {}
function Set-Password {}