Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bgelens/58c7854b9a111a46363deccf13ea7937 to your computer and use it in GitHub Desktop.
Save bgelens/58c7854b9a111a46363deccf13ea7937 to your computer and use it in GitHub Desktop.
$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"
}
@bgelens
Copy link
Author

bgelens commented Sep 14, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment