AWS SSM AWS-RunPowerShellScript命令无法执行cmd.exe / c

时间:2019-09-30 12:40:10

标签: powershell cmd aws-ssm

我正在尝试使用AWS SSM send-command在新的命令窗口中的Windows EC2实例(Windows Server 2012 R2)中运行以下三个命令。

cd C:\dir_1\dir_2
set NODE_ENV=devl
npm start

我尝试使用下面的boto代码。

myparmeter = {}
run_cmd = "start cmd.exe /c " + "cd C:\\dir_1\\_dir_2" + " ; " +  "set NODE_ENV=devl" + " ; " + "npm start"
myparmeter['commands'] = [run_cmd]
myparmeter['executionTimeout'] = ["3600"]
ssm_response = ssm.send_command(InstanceIds=[PARSED_ARGS.instance_id],  \
                                DocumentName="AWS-RunPowerShellScript", \
                                TimeoutSeconds=600, \
                                Parameters=myparmeter)    

但是在ssm命令输出中,它给了我这个错误

错误

Start-Process : A positional parameter cannot be found that accepts argument 
'cd'.
At C:\ProgramData\Amazon\SSM\InstanceData\...\awsrunPowerShellScript\0.awsrunPower
ShellScript\_script.ps1:1 char:1
+ start cmd.exe /c cd 'C:\dir_1\dir_2' ; set NODE_ENV=devl ; npm 
star ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterB 
indingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell 
.Commands.StartProcessCommand*

0 个答案:

没有答案