首页 > 解决方案 > Azure 自动化 Powershell Runbook 无法加载程序集

问题描述

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

输出

在此处输入图像描述

对此有任何想法吗?

标签: azurepowershellazure-automation

解决方案


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

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

在此处输入图像描述

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"

输出

在此处输入图像描述


推荐阅读