powershell - 从 devops 执行脚本时,Powershell 模块不可见
问题描述
我编写了一个 PowerShell 脚本,它使用 ReportingServicesTools 在项目构建终止后将报表部署到 PowerBI 报表服务器。当以我自己的身份登录服务器并执行脚本时,模块成功导入并执行脚本。
当我使用 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
- 引用整个路径,而不仅仅是脚本中的模块名称。
解决方案
推荐阅读
- entity-framework-core - EF Core 5:TrackGraph 更新多对多关系
- plot - 从下拉列表中选择图表类型
- go - 使用反射检查结构字段类型
- html - CSS 不样式化 div
- python - ggplot 和 plotnine 中的自由 y 轴
- reactjs - 在安装时避免成帧器运动初始动画
- javascript - axios拦截器过期时间
- salesforce - 如何使用 soql 在活动表中为 simple_salesforce 获取计算字段的值
- javascript - 连接到 mysql 数据库时出现对话框流错误
- javascript - 当我在另一个数组上调用 shift 时,数组被修改