Created
June 24, 2021 09:39
-
-
Save theonlyway/43b172d3afa1aa6714f38d7d8f96aceb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-AWSSAMLAssertion -rolescope All | |
foreach ($stsrole in $global:stsroles) | |
{ | |
Set-AWSCredentials -AccessKey $stsrole.credentials.AccessKeyId -SecretKey $stsrole.credentials.SecretAccessKey -SessionToken $stsrole.credentials.SessionToken | |
$checks = Get-ASATrustedAdvisorChecks -Language en | |
$i = 0 | |
$account = Get-IAMAccountAlias | |
if ($stsrole.credentials.Expiration -gt (Get-Date)) | |
{ | |
$ASADetails = @() | |
$ASADetailsCSV = @() | |
foreach ($item in $checks) | |
{ | |
Write-Verbose -Message "Getting results for $($item.Name) - Number $($i) out of $($checks.Count) for $($account)" | |
$results = Get-ASATrustedAdvisorCheckResult -CheckId $item.Id | |
$ASADetailsCSV += New-Object -TypeName PSObject -Property @{ | |
Account = $account | |
Check = $item.Name | |
Description = $item.Description | |
Category = $item.Category | |
Status = $results.Status | |
NumOfFlaggedResources = ($results.FlaggedResources).Count | |
} | |
$ASADetails += New-Object -TypeName PSObject -Property @{ | |
Check = $item.Name | |
Description = $item.Description | |
Category = $item.Category | |
Status = $results.Status | |
NumOfFlaggedResources = ($results.FlaggedResources).Count | |
} | |
$i++ | |
} | |
} | |
$ASADetails | | |
Select-Object -Property Status, NumOfFlaggedResources, Category, Check, Description | | |
Export-Excel -Path C:\Temp\ASA.xlsx -WorkSheetname $account -AutoSize -AutoFilter -ConditionalText $( | |
New-ConditionalText -Text error -ConditionalTextColor black -BackgroundColor red | |
New-ConditionalText -Text ok -ConditionalTextColor black -BackgroundColor green | |
New-ConditionalText -Text warning -ConditionalTextColor black -BackgroundColor yellow | |
) | |
$ASADetailsCSV | | |
Select-Object -Property Account, Status, NumOfFlaggedResources, Category, Check, Description | | |
Export-Csv -NTI -Path C:\Temp\ASA.csv -Append | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment