Get AWS IAM credentials report script
Quick powershell script to generate and save AWS IAM credentials report to csv format on a local location.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Import-Module AWSPowerShell $reportLocation = "C:\report" if (!(test-path($reportLocation))){ New-Item -ItemType Directory -Path $reportLocation } $date = get-date -Format dd-MM-yy-hh-mm-ss $reportName = "aws-credentials-report-$date.csv" $reportPath = Join-Path -Path $reportLocation -ChildPath $reportName
do { $result = Request-IAMCredentialReport Start-Sleep -Seconds 10 } while ($result.State.Value -notmatch "COMPLETE")
$report = Get-IAMCredentialReport -AsTextArray
$report = $report|ConvertFrom-Csv
$report | Export-Csv -Path $reportPath -NoTypeInformation
|