Created
June 18, 2020 12:27
-
-
Save pmatthews05/8418e59be0a3ff808cd91b592b13e582 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
#Get all Permission for the Service prinipal ObjectId. | |
$exisitingCollection = az ad app permission list-grants --filter "clientId eq '$($ServicePrincipalObjectId)' and consentType eq 'AllPrincipals'" | ConvertFrom-Json | |
#Get a access Token | |
$tokenResponse = az account get-access-token --resource-type ms-graph | convertFrom-Json | |
$existingCollection | ForEach-Object { | |
$existing = $PSItem | |
#Get the PermissionGrant | |
$apiUrlPatch = "https://graph.microsoft.com/v1.0/oauth2Permissiongrants/$($existing.objectId)" | |
$body = @{ | |
scope = "" | |
} | |
#Patch with an empty scope. | |
Invoke-RestMethod -uri $apiUrlPatch -Headers @{Authorization = "Bearer $(tokenResponse.accessToken)"} -Method $PATCH -Body $($body | ConvertTo-Json) -ContentType "application/json" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment