Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
On-demand Azure Policy Scan with Azure CLI and Powershell
# Based on @maikvandergaag work:
$account = (az account show -o json | ConvertFrom-Json)
$subscriptionId = $
$tenantId = $account.homeTenantId
$token = (az account get-access-token --tenant $tenantId -o json | ConvertFrom-Json).accessToken
$authHeader = @{
'Authorization'='Bearer ' + $token
$restUri = "$subscriptionId/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation?api-version=2019-10-01"
Invoke-webrequest -Uri $restUri -Method POST -Headers $authHeader -UseBasicParsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment