Azure Automation Access load locally stored dlls

Rohit Jarodia 26 Reputation points
2022-07-25T11:04:49.117+00:00

Hi, I am trying to load some DLLs in my script which is stored locally, and running the script using a hybrid runbook worker. getting below error

Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,546 Reputation points Moderator
    2022-07-28T10:09:58.697+00:00

    @Rohit Jarodia , thank you for the details. Please check if you are running the runbook on the Hybrid worker. For example, I have the following runbook:

    225717-image.png

    For test, I am using the "Test Pane" feature as highlighted in the image above.
    In the Test Pane, ensure that the "Hybrid Worker" option is selected and you have selected the "Hybrid Worker Group" on which you want to execute the runbook:

    225744-image.png

    Note that, when selecting the Hybrid Worker Group, you cannot control the machine which will pick up the job for execution. Therefore, if you have more than 1 server in the selected "hybrid Worker Group", ensure that all of them have the dlls and psm1 module available in the mentioned location (as available in the runbook script).

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,921 Reputation points
    2022-07-27T07:22:10.777+00:00

    Hi,

    The PowerShell script needs to load the assembly before it can use classes that the assembly exposes. To load assembly use Add-Type cmdlet.

    Add-Type -Path "WinSCPnet.dll"

    If you need to run the script from a different directory, you must specify a full path to the assembly. You can get the path from the script file path using the $PSScriptRoot automatic variable.

    Add-Type -Path (Join-Path $PSScriptRoot "WinSCPnet.dll")

    ----------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.