Last active
August 26, 2020 09:45
-
-
Save darrenjrobinson/aa20bf6ce63772f456365e298ba721b9 to your computer and use it in GitHub Desktop.
Convert Azure Active Directory AAD User from Member to B2B Member. Associated blogpost https://blog.darrenjrobinson.com/convert-azure-ad-users-from-members-to-b2b-members/
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
# Invite User Request | |
$inviteDetails = @{ | |
"invitedUserEmailAddress" = $externalEmail.otherMails[0] | |
"invitedUser" = @{"id" = $updatedUser.id } | |
"sendInvitationMessage" = $true | |
"inviteRedirectUrl" = "https://myapps.microsoft.com?ResourceTenantName.com" | |
"invitedUserMessageInfo" = @{ | |
"messageLanguage" = "en-AU" | |
"customizedMessageBody" = "Hi $($updatedUser.displayName), Your user account '$($updatedUser.userPrincipalName)' in the Contoso Azure Tenant has been migrated to a Guest account federated to your Fabrikam '$($updatedUser.otherMails[0])' account. After selecting 'Get Started' below you will be able to access Contoso using your Fabrikam account and credentials. All you access and privilages remain intact. Regards, Contoso IT" | |
} | |
} | |
$inviteBody = $inviteDetails | ConvertTo-Json | |
$invite = Invoke-RestMethod -Headers @{Authorization = "Bearer $($accessToken.AccessToken)"; "content-type" = "application/json" } ` | |
-Uri "https://graph.microsoft.com/v1.0/invitations" ` | |
-Method Post ` | |
-body $inviteBody | |
$invite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment