【发布时间】:2021-01-13 09:00:05
【问题描述】:
您好,我在 powershell 中运行 AWS CLI 命令,但无法从变量传递 ASG 名称:
$asgname = agaonline-system-ASG
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`Name`].Value, `$asgname`)].[AutoScalingGroupName]' --region eu-west-1 --output text | Out-File C:\temp\asg_name.txt
基本上,我无法将值 $asgname 传递给 AWS CLI 命令。
当我在命令下运行时,它给了我完美的输出:
aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`Name`].Value, `agaonline-system-ASG`)].[AutoScalingGroupName]' --region eu-west-1 --output text | Out-File C:\temp\asg_name.txt
谁能帮帮我。
【问题讨论】:
-
不确定查询字符串中的反引号,但是因为你在它周围使用了单引号,
$asgname不会被扩展。
标签: powershell aws-cli