Created
June 18, 2020 12:44
-
-
Save pmatthews05/a53a189ad845124b3f188098b0e21fe9 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 a access Token | |
$tokenResponse = az account get-access-token --resource-type ms-graph | convertFrom-Json | |
$body = @{ | |
clientId = $($servicePrincipal.objectId) | |
consentType = "AllPrincipals" | |
principalId = $null | |
resourceId = $($APIServicePrincipal.objectId) | |
scope = "User.Read Directory.ReadWrite.All" | |
startTime = "0001-01-01T00:00:00Z" | |
expiryTime = "2299-12-31T00:00:00Z" | |
} | |
$apiUrl = "https://graph.microsoft.com/v1.0/oauth2Permissiongrants" | |
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization = "Bearer $($tokenResponse.accessToken)" } -Method $method -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