Wednesday, 28 February 2018

AWS: IAM Users And Groups Report

The following script will pull the list of groups associated with IAM users in AWS. The user list can be generated by going to the IAM service in the AWS console and selecting "Credential Report".

$users = get-content iam-users.txt
$report = @() 
foreach ($user in $users)
{
    $info = Get-IAMGroupForUser -UserName $user | select -ExpandProperty GroupName
$report+="$user, $info"
}
$report | Out-File "user-groups.csv"