I am trying to execute powershell command through cloudformation template. it is throwing below error from the log. and the same time same command is working if i execute manually from the windows powershell.
please help me! i am very new to the powershell requirements.
2023-02-13 06:24:11,459 [ERROR] Command 2-Reboot (powershell.exe -Command {Import-Module -name AWSPowerShell; [string]$token = Invoke-RestMethod -Headers @{"X-aws-ec2-metadata-token-ttl-se
conds" = "21600"} -Method PUT -Uri http://169.254.169.254/latest/api/token; $instanceId = Invoke-RestMethod -Headers @{"X-aws-ec2-metadata-token" = $token} -Method GET -Uri http://169.254.
169.254/latest/meta-data/instance-id; Write-Output "reboot instance $instanceId through API"; Restart-EC2Instance -InstanceId $instanceId}) failed
2023-02-13 06:24:11,459 [DEBUG] Command 2-Reboot output: At line:1 char:84
+ ... WSPowerShell; [string]$token = Invoke-RestMethod -Headers @{X-aws-ec2 ...
+ ~
Missing '=' operator after key in hash literal.
At line:1 char:84
+ ... WSPowerShell; [string]$token = Invoke-RestMethod -Headers @{X-aws-ec2 ...
+ ~
The hash literal was incomplete.
At line:1 char:231
+ ... atest/api/token; $instanceId = Invoke-RestMethod -Headers @{X-aws-ec2 ...
+ ~
Missing '=' operator after key in hash literal.
At line:1 char:231
+ ... atest/api/token; $instanceId = Invoke-RestMethod -Headers @{X-aws-ec2 ...
+ ~
The hash literal was incomplete.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEqualsInHashLiteral
i am trying to execute powershell command through cloudformation template. it is throwing above error from the log. and the same time same command is working if I execute manually from the windows PowerShell.