1

我正在尝试通过 AWSCLI PowerShell 导出 EC2SecurityGroups。

Get-EC2SecurityGroup -Credential $Creds -Region us-east-1 > C:\us-east-1.txt

导出正常,但格式未详细显示所有内容。当我运行时:

aws ec2 describe-security-groups --region us-east-1 > C:\us-east-1.txt

显示详细的所有规则。

无论如何要使用 PowerShell 导出相同的格式?

谢谢!

4

1 回答 1

3

这些数据也都包含在适用于 PowerShell 的 AWS 工具中,但 PowerShell 本身不会像您期望的那样扩展嵌套对象输出。

使用 JSON 输出扩展所有嵌套对象:

Get-EC2SecurityGroup -Credential $Creds -Region us-east-1 | ConvertTo-JSON -Depth 5 | Out-File C:\us-east-1.txt

用类名展开所有嵌套对象:

Get-EC2SecurityGroup -Credential $Creds -Region us-east-1 | Format-Custom -Depth 5 -Expand Both
于 2017-01-27T19:03:43.613 回答