Created
November 7, 2019 09:35
-
-
Save MaxMelcher/dd5a40488a9c748e280ab35d02dcff62 to your computer and use it in GitHub Desktop.
on demand policy scan
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
$subscriptionID = “<your-subscription-ID-goes-here>" | |
# Get AAD Access Token | |
$azContext = Get-AzContext | |
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile | |
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile) | |
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId) | |
$authHeader = @{ | |
'Authorization'='Bearer ' + $token.AccessToken | |
} | |
# Call REST API to trigger policy evaluation on subscription scope | |
$uri = "https://management.azure.com/subscriptions/$subscriptionId/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation?api-version=2018-07-01-preview" | |
$Parameters = @{ | |
Uri = $uri | |
Method = "Post" | |
ContentType = "application/json" | |
Headers = $authHeader | |
} | |
Invoke-RestMethod @Parameters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment