I'm running into what I'm sure is a simple issue I'm overlooking. I'm trying to change an AWS EC2 InstanceType using the CLI via a Powershell Script. Everything is running fine up until I go to actually modify the InstanceType.
I've tried multiple different variations and combinations of escape characters to get this to work, but I can't so far.
Invoke-Expression 'aws ec2 modify-instance-attribute --instance-id $thisID --instance-type \"{`\"Value`\":`\"m4.large`\"}"'
What I'm trying to achieve is the equivalent to this:
aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --instance-type "{\"Value\": \"m1.small\"}"
'{"Value": "m4.large"}'. The single quote makes it a string literal.Invoke-Expression(or any other cmdlet) to synchronously invoke console applications: invoke them directly. Specifically,Invoke-Expressionshould generally be avoidedInvoke-Expressionoutside of PowerShell unless you know exactly what the implications are.