In this Azure ad tutorial, we will discuss how to add bulk guest users in Azure AD B2B from the Azure portal, also we will discuss how to add bulk users in Azure ad B2B collaboration using Powershell.
Table of Contents
How to add bulk guest users in Azure AD B2B from Azure Portal and PowerShell
We can use Azure active directory B2B collaboration to work with vendors or external partners. Here we can invite bulk guest users to our organization.
Add bulk users in Azure AD B2B Collaboration from Azure Portal
Microsoft allows us to add bulk users in Azure ad B2B collaboration from the Microsoft Azure portal throw a CSV file.
The external users can have any type of account like Gmail.com or yahoo.com or outlook.com.
Login to the Azure portal. You can create a free Azure account.
Then select the Azure active directory.
Then Click on Users which is under Manage.

This will display all the users, here click on Bulk invite, which will display the bulk invite users page and an option to download a template, it is a CSV file.

This is basically a sample or template which you can modify and upload here. Here you can add all the guest users you want to invite.
The CSV file looks like below:

You can modify and add all the guest users you want to invite.

Once the CSV file is ready, upload it like below:

Click on Submit.
Once it is done, it will show a successful message like below:

You can also click on the “Click here to view the status of each operation” link to check the status of each request.
The users will appear as Guests in the Azure AD.

The users will receive the email invitations and they can accept the invitation.
Check Bulk Operations Results
You can also check the bulk operations results. Click on Bulk operation results from the left navigation and it will display the File name, Status, Success, Failures, Total requests, etc.

This is how we can add bulk guest users in Azure AD B2B collaboration from Azure Portal.
Add bulk users in Azure AD B2B Collaboration using PowerShell
We can also use PowerShell to add bulk guest users in Azure AD B2B collaboration.
To work with PowerShell, make sure you have installed the latest version of the AzureADPreview module.
Install-Module AzureADPreview
You can also run the below command to check which AzureAD PowerShell module has been installed in your system.
Get-Module -ListAvailable AzureAD*

You can check the below tutorial on how to install the AzureADPreview PowerShell module.
Once you install the AzureADPreview module, next you need to make the CSV file ready.
Create a CSV file with the following columns:
- Name
- InvitedUserEmailAddress
You can create an excel and save the file in .csv format in your system drive. The excel file looks like below:

Now, run the below PowerShell command in PowerShell ISE to add bulk guest users in Azure AD B2B using PowerShell.
Connect-AzureAD -TenantDomain "SPSkyTraining.onmicrosoft.com"
$csvfilepath = import-csv e:\Bijay\BulkUsers.csv
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "Hello. Join TSInfo Team."
foreach ($email in $csvfilepath)
{New-AzureADMSInvitation `
-InvitedUserEmailAddress $email.InvitedUserEmailAddress `
-InvitedUserDisplayName $email.Name `
-InviteRedirectUrl https://myapps.microsoft.com `
-InvitedUserMessageInfo $messageInfo `
-SendInvitationMessage $true
}
You can see the invites like below:

You can check the users in Azure AD.
Or also, you can check the guest users in Microsoft 365 admin center.

You may like the following Azure tutorials:
In this tutorial, we learned how to invite bulk guest users in Azure AD collaboration using PowerShell.
Hello, firstly id like to say this is a very good script. i have tried it and it has helped especially with Bulk guest user creations. one thing i have noticed is that i receive the below error after running the script. Any idea why?
-InvitedUserMessageInfo : The term ‘-InvitedUserMessageInfo’ is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At C:\Guest\GuestAccess.ps1:13 char:7
+ -InvitedUserMessageInfo $messageInfo `
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-InvitedUserMessageInfo:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Hi Malcolm McDonald,
Not sure if you are using the AzureADPreview module or not. Can you try installing that and try once? You can follow the below article to install AzureADPreview module
https://azurelessons.com/connect-to-azure-powershell/
So I’m wondering if you have an answer for what happens if one of the users in a csv is already a guest in Azure? Will you get an error or will it just send the invite again? Ideally I would hope it would error out for that line of the csv.
So just to test, I uploaded a csv, and just now i uploaded the same csv. no errors. When I look in azure, I only see one entry for each user, but just wondering if you had a definitive answer for this.
Thanks!
Hi, I want to try the bulk user invite but can not see any column with firstname and surname in the template. Is this not posible to do?