Within my DSC script in using a xDSC resource but i need to import this module onto the destination host. Is it possible to use DSC to copy the module to the destination and import all within a single script? or do i need to create to scripts, 1 to import the module and then the DSC script?
If you’re using Push, the resources need to exist on the destination before you start-DSCConfiguration. If you’re using pull, they need to exist on the pull server.
If you are using Push the modules already need to be on the destination server as Missy Januszko said.
So you have to manually move the modules to destination before running Start-DSCConfiguration.
In theory, yes, you could run first one Start-DSCconfiguration that copy over the modules, and then a second that do what you want it to do.
Part of my job is continuously refresh test environments with copies of our production systems, and as part of the refresh the servers need certain configurations applied which I do with multiple xDSC resources.
I manually push the 1st DSC script to install various windowsfeatures, creates folders and copies files, user accounts, and also copies across the xdsc modules/resources which are needed.
The I then push the second script that uses the xdsc modules made available by the first script and finishes the configuration, like amending IIS permission or local security polices. These can then be re-run to keep the correct node state.
I know I can do this with PowerShell, but it’s so easy with DSC.
So basically what I am asking, was there a way to trigger the first DSC and then the second without me manually running the 2nd.
You can use a DSC feature called ‘Push to Pull’. Basically you can push the configuration but can still configure LCM to automatically download the modules when needed from either file based pull server or web based pull server. LCM settings would look something like: