Created
May 28, 2020 11:14
-
-
Save bgelens/58c7854b9a111a46363deccf13ea7937 to your computer and use it in GitHub Desktop.
This file contains 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
$tenantId = '' | |
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext | |
$token = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate( | |
$context.Account, | |
$context.Environment, | |
$context.Tenant.Id.ToString(), | |
$null, | |
[Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, | |
$null, | |
'https://management.azure.com/' | |
) | |
$subscriptions = Get-AzSubscription -TenantId $tenantId | |
$body = @{ | |
subscriptionId = @( | |
$subscriptions.SubscriptionId | |
) | |
subscriptionName = @( | |
$subscriptions.Name | |
) | |
} | ConvertTo-Json | |
@( | |
'Azure CIS 1.1.0' | |
'PCI DSS 3.2.1' | |
'SOC TSP' | |
'ISO 27001' | |
) | ForEach-Object -Process { | |
$escapedReportName = [uri]::EscapeDataString($_) | |
irm "https://s2.security.ext.azure.com/api/regulatoryCompliance/reports/executiveSummary?standardName=$escapedReportName" -Headers @{ | |
Authorization = "Bearer $($token.AccessToken)" | |
} -Method Post -Body $body -OutFile "/Users/bengelens/Desktop/$_.pdf" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@scarytoon I just noticed @JustinGrote created a function that can fetch a token as the portal app. I did not check it out yet but it might be usable for this scenario as well.
https://github.com/JustinGrote/AzSpotPricing/blob/main/Modules/Az.SpotPricing/Get-AzPortalToken.ps1