PowerShell AWS命令:未知令牌/

ezykj2lf  于 2023-04-21  发布在  Shell
关注(0)|答案(1)|浏览(95)

我正在尝试运行此命令;

aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.to-port,Values=22 --query 'SecurityGroups[?((IpPermissions.IpRanges.CidrIp == "0.0.0.0/0") || (IpPermissions.Ipv6Ranges.CidrIpv6 == "::/0"))].[GroupId]' --profile "prod" --region "us-east-1" | out-file $output -Encoding ASCII -append

它抛出以下错误;未知令牌/:(PowerShell似乎不喜欢“/”)

Bad value for --query SecurityGroups[?((IpPermissions.IpRanges.CidrIp == 0.0.0.0/0) || (IpPermissions.Ipv6Ranges.CidrIpv6 == ::/0))].[GroupId]: Bad jmespath 
expression: Unknown token /:
SecurityGroups[?((IpPermissions.IpRanges.CidrIp == 0.0.0.0/0) || (IpPermissions.Ipv6Ranges.CidrIpv6 == ::/0))].[GroupId]
  • 如何编写命令并告诉PowerShell斜杠只是斜杠并运行它?*

谢谢大家!
运行并列出具有公共IP地址的所有安全组的代码。

rur96b6h

rur96b6h1#

尝试使用反斜杠作为转义符:

aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.to-port,Values=22 --query 'SecurityGroups[?((IpPermissions.IpRanges.CidrIp == "0.0.0.0\/0") || (IpPermissions.Ipv6Ranges.CidrIpv6 == "::\/0"))].[GroupId]' --profile "prod" --region "us-east-1" | out-file $output -Encoding ASCII -append

相关问题