从devops执行脚本时,Powershell模块不可见

时间:2019-01-30 12:02:17

标签: powershell azure-devops self-hosting azure-devops-self-hosted-agent

我编写了一个PowerShell脚本,该脚本在项目构建终止后使用ReportingServicesTools将报告部署到PowerBI Report Server。当以我自己的身份登录服务器并执行脚本时,模块将成功导入并执行脚本。

当我使用Powershell任务在Azure DevOps发布管道中执行目标脚本时,返回以下错误:

  

import-module:指定的模块“ ReportingServicesTools”不是   已加载,因为在任何模块目录中均未找到有效的模块文件。   在D:\ DevOps Agent \ DeploySSRS2.ps1:3 char:1 import-module -Name   ReportingServicesTools

我们正在使用自托管代理进行发行和构建,并且服务器已安装PS 5。

我尝试过:

  • 按照MSDN所说,将模块移到 C:\ Program Files \ WindowsPowerShell \ Modules 中,这将使该模块对所有用户可见。
  • 将模块添加到 C:\ Windows \ system32 \ WindowsPowerShell \ v1.0 \ Modules
  • 引用整个路径,而不仅仅是引用脚本中的模块名称。

0 个答案:

没有答案