Azure Automation Powershell runbook 无法加载程序集

Azure Automation Powershell runbook failed to load assembly

我是 运行 在 Azure 门户上的代码

Write-Output "Starting"
$assemblyPath = "C:\Modules\Global\Azure\Compute\Microsoft.Exchange.WebServices.dll"
dir $assemblyPath

Write-Output "1"        
Add-Type -Path $assemblyPath
Write-Output "2"

输出

对此有什么想法吗?

要加载.dll程序集,您可以参考步骤。

1.Navigate到你的自动化账号在门户->模块->添加模块,压缩Microsoft.ApplicationInsights.dll文件到Microsoft.ApplicationInsights.zip,然后上传。上传后,您将在门户中找到它。

2.Change $assemblyPath,你的完整命令应该如下所示,它会正常工作。

Write-Output "Starting"
$assemblyPath = "C:\Modules\User\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.dll"
dir $assemblyPath

Write-Output "1"        
Add-Type -Path $assemblyPath
Write-Output "2"

输出: