1
처음 포스터가 여기 있습니다.IAM 그룹 및 사용자를 쿼리 할 때 CSV 출력을 얻으려면 어떻게합니까?
AWS에서 그룹 멤버쉽을 출력하는 작은 스크립트를 만들었습니다.
나는 원하는 결과를 출력한다는 점에서 스크립트를 가지고 있지만 읽을 수있는 형식의 데이터를 CSV 파일로 가져 오는 데 도움이 필요합니다.
$awsgroupnames = Get-IAMGroups
$accountname = Get-IAMAccountAlias
foreach ($awsgroupname in $awsgroupnames) {
$groupuser = Get-IAMGroup -groupname ($awsgroupname.GroupName)
$usernames = $groupuser.users | select UserName
write-host $accountname ($awsgroupname.groupname) ($usernames.username)
}
출력은 다음과 같습니다.
Account Alias - Group - User
aws-dxxxd-mxxer axx-admin xxhie sxxwj bhxxwk hxxv rxxerd cxxx axxw-sf-msdsmt
aws-dxxxd-mxxer aws-casesupport
aws-dxxxd-mxxer aws-readonly gixxxi mxxxxilj kxxng bxxnst txxxgd rxm kxxxrs
aws-dxxxd-mxxer billing-admin bsdffdk crcccdi
aws-dxxxd-mxxer Billing_Access
aws-dxxxd-mxxer vdc-axxxs mxxxab rxxxd cxxxmi aws-srxxxc-mxxt
aws-dxxxd-mxxer vpc-axxxn mxxxab mxxxj mxxxnr
다음 형식으로 CSV로 내보내려면 어떻게해야합니까?
Account Alias - Group1 - User1
Account Alias - Group1 - User2
Account Alias - Group1 - User3
Account Alias - Group2 - User1
Account Alias - Group2 - User2
Account Alias - Group3 - User1
Account Alias - Group4 - Blank for no user
등등.