【问题标题】:Terraform Azure VM Extension failed with too long command for Powershell script executionTerraform Azure VM 扩展因 Powershell 脚本执行命令太长而失败
【发布时间】:2022-06-10 21:40:18
【问题描述】:

在 Terraform 中执行 Azure VM 扩展以运行 Powershell 脚本时出现以下错误。你能帮我解决这个错误吗?

命令执行完成,但失败,因为它返回了一个非零退出代码:“1”。该命令有一个错误输出:'命令行太长。 '

这是我使用的受保护设置详细信息

"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.secvmtf.rendered)}')) | Out-File -filepath hybrid.ps1\" && powershell -ExecutionPolicy Unrestricted -File hybrid.ps1"

【问题讨论】:

  • 您使用的是哪个版本的 PowerShell?

标签: powershell terraform azure-vm


【解决方案1】:

根据本文档,脚本参数数据不能超过256Kb的大小,否则不会执行。

脚本必须是 base64 编码的。该脚本可以选择是 压缩包。脚本设置可以在公共或受保护的情况下使用 设置。 脚本参数数据的最大大小为 256 KB。 如果脚本超过这个大小,它将不会被执行。

https://github.com/Azure/custom-script-extension-linux/blob/master/README.md#14-script

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 2021-12-29
    • 2015-08-05
    • 2021-06-14
    • 2018-10-30
    • 2021-09-28
    • 2012-04-12
    相关资源
    最近更新 更多