Azure自动化Powershell Runbook无法加载程序集

时间:2018-10-12 07:22:31

标签: azure powershell azure-automation

我正在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"

输出

enter image description here

对此有任何想法吗?

1 个答案:

答案 0 :(得分:1)

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

1。在门户网站->模块->添加模块中导航到您的自动化帐户,将Microsoft.ApplicationInsights.dll文件压缩为Microsoft.ApplicationInsights.zip,然后上传。上传后,您将在门户中找到它。

enter image description here

2。更改$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"

输出

enter image description here