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

Argo Workflow执行PowerShell脚本报错,请求协助排查修复

修复Argo Workflows执行PowerShell脚本的Exec格式错误

错误原因

报错Exec format error是因为Argo生成的临时脚本/argo/staging/script未指定解释器,系统尝试直接执行时无法识别其格式;同时原配置中command: ["pwsh", -c]存在YAML语法错误(-c未加引号),且配置逻辑不符合Argo Script模板的执行规则。

修复方案

方案一:添加PowerShell Shebang行

在脚本开头加入#!/usr/bin/env pwsh,明确指定脚本解释器,无需额外配置command:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: powershell-002
  namespace: argo-workflows
spec:
  entrypoint: run-powershell
  templates:
    - name: run-powershell
      script:
        image: mcr.microsoft.com/powershell:latest
        source: |
          #!/usr/bin/env pwsh
          Write-Host "Hello, Argo! This is a PowerShell script."
          $date = Get-Date
          Write-Host "The current date and time is: $date"

方案二:正确配置Command与Args

通过command指定pwsh解释器,args指定执行临时脚本的参数:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: powershell-002
  namespace: argo-workflows
spec:
  entrypoint: run-powershell
  templates:
    - name: run-powershell
      script:
        image: mcr.microsoft.com/powershell:latest
        command: ["pwsh"]
        args: ["/argo/staging/script"]
        source: |
          Write-Host "Hello, Argo! This is a PowerShell script."
          $date = Get-Date
          Write-Host "The current date and time is: $date"

验证方法

应用修改后的Workflow配置,执行以下命令查看实时状态:

argo submit -f your-workflow.yaml --watch

若工作流成功执行,会输出PowerShell脚本中的日志内容。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 05:27:13