Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active August 26, 2020 09:45
Show Gist options
  • Save darrenjrobinson/aa20bf6ce63772f456365e298ba721b9 to your computer and use it in GitHub Desktop.
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/
# 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