You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps自托管代理执行任务失败:Windows环境报错求助

解决Azure DevOps Pipeline在Windows虚拟机上的任务执行错误

修复方案

  • 检查PowerShell执行策略
    以管理员身份打开PowerShell,运行Get-ExecutionPolicy,若结果为Restricted,执行Set-ExecutionPolicy RemoteSigned(按提示确认),允许脚本正常运行。

  • 强制代理使用Windows PowerShell 5.1
    部分旧任务仅兼容Windows Desktop PowerShell(5.1版本),而非PowerShell Core(7+)。操作方式:

    1. 停止Azure DevOps代理服务
    2. 打开代理安装目录下的config.cmd,重新配置代理,在PowerShell版本选项中选择Windows PowerShell
    3. 或直接设置环境变量VSTS_AGENT_PS_EDITION=Desktop后重启代理服务
  • 确认代理运行账户权限
    打开系统服务管理器,找到Azure Pipelines Agent服务,确保其以本地系统账户或拥有管理员权限的Windows账户运行,避免权限受限导致任务执行失败。

  • 更新Azure DevOps代理版本
    卸载当前代理,下载最新Windows版代理重新安装配置,旧版本代理可能存在兼容性bug。

  • 检查任务配置
    在Pipeline编辑界面,确保Web Config Transform、Copy Files等任务的PowerShell版本设置为Windows PowerShell 5.1,而非PowerShell Core。

错误提示原文:
##[error]The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.
##[debug]System.InvalidOperationException: The current operating system is not capable of running this task. That typically means the task was written for Windows only. For example, written for Windows Desktop PowerShell.

内容的提问来源于stack exchange,提问作者Mr W

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 10:35:40