How to resolve "Cannot bind parameter 'Path' to the target" error when using Add-Type in PowerShell Azure runbook?

Karthika Ganesamoorthi 20 Reputation points
2023-10-30T12:47:40.7+00:00

Hi, I have added the Microsoft.AnalysisServices.AdomdClient.dll file as a zip file in the module using add module in an Azure PowerShell runbook (version 5.1). I am now referencing it in my PowerShell script using:

Add-Type -Path "C:\Modules\User\Microsoft.AnalysisServices.AdomdClient\Microsoft.AnalysisServices.AdomdClient.dll"

However, I am receiving the following error:

`System.Management.Automation.ParameterBindingException: Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\Modules\User\Microsoft.AnalysisServices.AdomdClient\Microsoft.AnalysisServices.AdomdClient.dll' because it does not exist."

I checked the correct path using the command:

Get-ChildItem -Path C:\ -Filter Microsoft.AnalysisServices.AdomdClient.dll -Recurse -ErrorAction SilentlyContinue

The result is same as what I have written in Add-path.

How can I resolve this error and successfully reference the DLL file in my script?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,195 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,328 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karthika Ganesamoorthi 20 Reputation points
    2023-10-30T13:17:02.0966667+00:00

    I ran this command

    Get-ChildItem -Path C:\ -Filter Microsoft.AnalysisServices.AdomdClient.dll -Recurse -ErrorAction SilentlyContinue

    3-4 time, I got new path, Then it worked;