WebAdministration Module Requirement on Custom Resource

We have a custom DSC resource that sets Web Configuration Properties. It uses the Get-WebConfigurationProperty and Set-WebConfigurationProperty cmdlets so it relies on the WebAdministration module being available. Since the base image of our servers don’t come with IIS installed, the WebAdministration module isn’t available. Currently we have to lay down a configuration which installs roles and features, including IIS, then we have to apply a second configuration which applies the rest of our settings via our custom resources. We’re trying to combine these 2 configs into one to eliminate steps but when I apply the combined config, DSC throw an error in the event log saying it can’t find the WebAdministration module.

Error Message: Importing module IISItemProperty failed with error - The specified module ‘WebAdministration’ was not loaded because no valid module file was found in any module directory.

I know that we are getting this error because the LCM checks all the dependencies before running the configuration. Has anyone else out there experienced this issue and figured out a workaround?

Matt

This checking of dependencies feels like a variant of my problem: https://powershell.org/forums/topic/push-mode-with-resourcerepositoryshare-problem-with-custom-resources.

Until I can get ResourceRepositoryShare working (which I think would help you?) I’m copying the custom resources from a UNC to C:\Program Files\WindowsPowerShell\Modules before applying the configuration.

It is same problem as described here as well: https://powershell.org/forums/topic/how-do-i-use-resource-when-module-did-not-finish-importing-yet/

In order for DSC team to has visibility on this issue I recommend filing a userVoice request (https://windowsserver.uservoice.com/forums/301869-powershell).

I posted the idea to UserVoice. Feel free to upvote it if you’re running into the same issue.

https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/13504089-allow-lcm-to-accomodate-module-dependencies-that-g

You can change the $env:PSModulePath on each node to point to a network share where you place all the modules. This will ensure the server will find it on the initial DSC script running. After that as the final step of your script, change the value to its original value.

Naturally in between you would already have copied the necessary module to the specifc node for future runs.

Ive seen a script before that scans DSC scripts for any “Import-Module” commands and then goes out and copies the module. Nothing says you need to do ALL in one step, you can do it in stages. Send one configuration and then send a second configuration for example.

That’s a good idea for regular modules but the problem is that the WebAdministration module gets installed with IIS and can’t just be copied to the server. It has some other dependencies on DLLs within IIS so I don’t think referencing them remotely would work either. It will probably still look locally for those DLLs and fail.