I have two separate Azure AD instances, 'a' and 'b'. I want to invite users of 'b' into 'a' (as a guest user) programmatically. For this, I'm using the AzureAD Powershell module:
$Result = New-AzureADMSInvitation `
-InvitedUserEmailAddress $Email `
-InvitedUserDisplayName $DisplayName `
-InviteRedirectUrl $InviteRedirectUrl `
-SendInvitationMessage $false
The invitation should be accepted automatically, without sending an invitation email. That's why I pass the parameter -SendInvitationMessage $false
. I noticed, however, that a user cannot log in before accepting the invitation (eventhough no email was sent).
Is there a way to programmatically accept the invitation on behalf of the user? Either by using the AzureAD Powershell module, or through a workaround (e.g. calling the Graph API)?
I'm admin of both Azure AD instances, and since I just created the user myself, I also have the credentials. I'm looking to avoid the hassle of manually accepting the invitation.