DSC does not locate/load module it needs as part of a configuration

Welcome Forums DSC (Desired State Configuration) DSC does not locate/load module it needs as part of a configuration

This topic contains 0 replies, has 1 voice, and was last updated by  Charlie 1 month, 3 weeks ago.

  • Author
    Posts
  • #162632

    Participant
    Topics: 7
    Replies: 1
    Points: 38
    Rank: Member

    Can someone please help me with the following issue

    I am using DSC in Azure (Azure Automation DSC)

    I receive the following error message,

    PowerShell DSC resource MSFT_ScriptResource failed to execute Get-TargetResource functionality
    with error message: The term 'MyFunction' is not recognized as the name of a cmdlet, function, script file, or
    operable program.

    Here is the background

    function MyFunction {
    
    #code here ......
    
    }
    Export-ModuleMember -Function MyFunction
    

    I saved the above as a .PSM1 and imported to Azure Automation (to the Modules section)
    I see the module in Azure Automation and when I click on it I can see the MyFunction 'activity' so all looks good

    I then do the following in my DSC

    Configuration MyConfig {
    
    Import-DSCResource -ModuleName MyFunction
    
    Script MyScript {
    getScript = {code here}
    
    test-Script = {
    code .....
    $X = MyFunction
    code...
    }
    
    setScript = {coe here}
    
    }
    

    So basically I am calling MyFunction (which shows as an 'activity' when looking at the module in the modules section of azure automation). However it cannot be found hence the message at the top of this post

    However I receive the error that the MyFunction is

    Do you know what I am doing wrong here please? am I missing a step, do I need to do something else?

    Thanks

    CXMelga

You must be logged in to reply to this topic.