尝试从CloudFormation :: Init运行PowerShell脚本时遇到语法错误

时间:2018-08-01 14:50:43

标签: windows amazon-web-services powershell amazon-cloudformation

当我的实例启动并且遇到语法错误时,我正在尝试运行PS1脚本:

2018-08-01 13:15:45,951 [DEBUG] Running command 10-test
2018-08-01 13:15:45,951 [DEBUG] No test for command 10-test
2018-08-01 13:15:45,951 [ERROR] Command 10-test ('C:\ProgramData\Amazon\Scripts\install_agent.ps1') failed
2018-08-01 13:15:45,951 [DEBUG] Command 10-test output: The filename, directory name, or volume label syntax is incorrect.

2018-08-01 13:15:45,951 [ERROR] Error encountered during build of config: Command 10-test failed
Traceback (most recent call last):
  File "cfnbootstrap\construction.pyc", line 544, in run_config
  File "cfnbootstrap\construction.pyc", line 138, in run_commands
  File "cfnbootstrap\command_tool.pyc", line 117, in apply
ToolError: Command 10-test failed
2018-08-01 13:15:45,951 [ERROR] -----------------------BUILD FAILED!------------------------
2018-08-01 13:15:45,951 [ERROR] Unhandled exception during build: Command 10-test failed
Traceback (most recent call last):
  File "cfn-init", line 171, in <module>
  File "cfnbootstrap\construction.pyc", line 129, in build
  File "cfnbootstrap\construction.pyc", line 530, in build
  File "cfnbootstrap\construction.pyc", line 544, in run_config
  File "cfnbootstrap\construction.pyc", line 138, in run_commands
  File "cfnbootstrap\command_tool.pyc", line 117, in apply
ToolError: Command 10-test failed

这是我的CFN模板的一部分:

"config": {
   "commands": {
      "10-test": {"command": "'C:\\ProgramData\\Amazon\\Scripts\\install_agent.ps1'"},
     },
     "files": {
         "C:\\ProgramData\\Amazon\\Scripts\\install_agent.ps1": {
            "source": "https://my-bucket/software/trend-micro/install_agent.ps1",
            "authentication": "S3AccessCreds"
          }
       }
   }

该脚本已从S3正确下载,并且如果我从Windows实例本身上的PowerShell命令提示符处运行相同的命令(C:\ ProgramData \ Amazon \ Scripts \ install_agent.ps1),它将正常运行。我在引号(单引号,双引号,转义符)上尝试了多种不同的变体,并尽可能简化了所有内容,但这仍然行不通。

有人可以告诉我我要去哪里了吗?我敢肯定这只是简单的事情,但我无法弄清楚。嗯......

0 个答案:

没有答案