Created
June 19, 2020 08:12
-
-
Save astaykov/59697484bedfcb7984c81d16d20527e8 to your computer and use it in GitHub Desktop.
Adding claims mapping policy for Azure AD to emit email_verified claim
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
Connect-AzureAD -Confirm | |
Import-Module AzeruADPreview | |
$appID = "...guid-of-the-AppID..." | |
$policyName = "Add email_verified to claims" | |
$sp = Get-AzureADServicePrincipal -Filter "servicePrincipalNames/any(n: n eq '$appID')" | |
$existingPolicies = Get-AzureADServicePrincipalPolicy -Id $sp.ObjectId ` | |
| Where-Object { $_.Type -eq "ClaimsMappingPolicy" } | |
if ($existingPolicies) { | |
$existingPolicies | Remove-AzureADPolicy | |
} | |
$policy = New-AzureADPolicy -Definition @('{"ClaimsMappingPolicy":{"Version":1,"IncludeBasicClaimSet":"true", "ClaimsSchema":[{"value":"true","JwtClaimType":"email_verified"}]}}') -DisplayName $policyName -Type "ClaimsMappingPolicy" | |
Add-AzureADServicePrincipalPolicy -Id $sp.ObjectId -RefObjectId $policy.Id | |
Write-Output ("New claims mapping policy '{0}' set for app '{1}'." -f $policy.DisplayName, $sp.DisplayName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment