【问题标题】:Azure Automation Powershell runbook failed to load assemblyAzure 自动化 Powershell Runbook 无法加载程序集
【发布时间】:2018-10-12 16:11:17
【问题描述】:

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

输出

对此有什么想法吗?

【问题讨论】:

  • 当然失败了,如果从azure 门户运行,则没有路径。你应该从你的本地电脑上运行它,它可以定位你指定的路径。
  • @IvanYang 表示在天蓝色门户中没有办法
  • 你可以解释的更清楚一些,比如add-type cmdlet之后,你接下来要做什么?
  • 我需要使用 azure 门户来运行它。我该怎么办?
  • @IvanYang 我想使用交换服务而不是 SMTP 发送邮件

标签: azure powershell azure-automation


【解决方案1】:

要加载.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"

输出:

【讨论】:

  • 非常感谢您的回答。但是我还有一个问题,我想使用交换服务而不是 SMTP 发送邮件。我使用了 Microsoft.Exchange.WebServices.dll,它具有 Send-EWSmail 功能,但这不起作用。 '$Credential=Get-AutomationPSCredential -Name 'ServiceAccount' Send-EWSmail -to "**@gmail.com" -Subject "Automated mail" -Body "PowerShell and Exchange rock!" -Credential $Credential' 请也帮我解决这个问题
  • 请再次查看上述评论。请帮忙
  • @SumitGarg 要使用Send-EWSmail,只需转到Browse Gallery 并导入模块,参考:i.stack.imgur.com/4EJkF.png
  • 是的,谢谢我的问题已解决。我使用了 Send-EWSmail 而不是 Send-EWSEmail
猜你喜欢
  • 2017-09-02
  • 2020-11-20
  • 2022-11-11
  • 1970-01-01
  • 1970-01-01
  • 2016-06-22
  • 1970-01-01
  • 2019-05-17
  • 1970-01-01
相关资源
最近更新 更多