0
votes

We would like to automate external user invitation in SharePoint. The manual process of what we are trying to achieve works but not the Powershell method.

Manual Process: Share a sharepoint site to an email (e.g. [email protected]) by invitation. When the invited user accepts the invitation, user creates a Microsoft account, that will create an account in our Azure AD tenancy with a UPN a-guest-user_anyemail.com#EXT#@mytenant.onmicrosoft.com. The user can login subsequently using the email as the login id ([email protected]).

Using Powershell Azure AD V2 modules Steps:

  1. Create users using powershell command

    New-AzureADUser -DisplayName "AGuest User" -PasswordProfile $PasswordProfile -AccountEnabled $true -MailNickName "aguestuser" -UserPrincipalName "[email protected]" -UserType "Guest" -OtherEmails "[email protected]"

  2. Add the users to a relevant SharePoint group (using Add-SPOUser powershell command)
  3. Users are emailed a link to the SharePoint site (for e.g. https://mytenant.sharepoint.com/sites/myexternalsite)

Once this is done, this user can log in successfully using [email protected], but not using an email i.e. [email protected]

Does any one know how to allow the external user to login using their email account when provisioned using Powershell? Thank you

1
After a lot of trial and error, I have found out that this can be done using the New Azure B2B api (currently in preview) command New-AxureADMSInvitation. This process creates a local guest account in the current Azure AD and when the user accepts invitation they can log in using their existing Microsoft account or create a new password.Aarun

1 Answers

0
votes

The New-AzureADUser Powershell command only create a Azure AD user, it will not invite the external user.

To invite the external user, you can using the SharePoint client library and others write many similar scripts. For example, you can refer the script from here.