I have created a custom PowerShell DSC resource that relies on a separate module being present on the node. I have the module on all nodes for all users (C:\Program Files\WindowsPowerShell\Modules). This all works as expected when not using PsDscRunAsCredential in a configuration. However, if I add PsDscRunAsCredential it is no longer able to find the module.
For example, the following runs fine when PsDscRunAsCredential is not included in the config, but returns the following error when it is included (Get-DbaLogin is a function in the module in question):
The term 'Get-DbaLogin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Get-DbaLogin:) [], CimException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : host1
I have also tested removing the need for the module, and then using PsDscRunAsCredential works as expected. Is there a way for the environment to import the module when using PsDscRunAsCredential?