I have an issue with my dsc config, on windows 10. I had to define a script block as I couldn't install WindowsIIS with dsc considering it wants a server sku. The following code is an example of a way to bypass it (sorta), but I can't call my modules or functions from the script block for some reason. Have a look:
Configuration update-settings
{
$hostname = $env:COMPUTERNAME
Node $hostname
{
Script whatever
{
GetScript = { return @{'Result' = 'something'} }
TestScript = { return $false }
# problem is here:
SetScript = { run-myfunction -args something }
}
}
}
I have a psm1 file elsewhere, and even if I do a Import-Module C:\MyFolder\PSModules\run-myfunctions.psm1 -force
in my dsc, it still gives me the following errors:
PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: The term 'run-myfunction' 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 : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : DESKTOPofMe
The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : DESKTOPofMe
Just an fyi, I did run and export my powershell modules correctly, and can access them on the commandline with run-myfunction
or run-myfunction2
, etc.
Any help would be appreciated, thank you :)