Setting Azure B2B Users as Members via the invitation

New Contributor

Hi All, apologies if I haven't spotted this answer in another post. I am a PowerShell newbie, I am looking for a command to invite Azure B2B users and make them as Members. I have been using the command Get-AzureADUser -SearchString | Set-AzureADUser -UserType member for individuals, but there is a need for me to bulk invite 100+ users and make them as members, any pointers will be very helpful. Many thanks in advance. Sabs

4 Replies

Hi @adam deltinger 


Thanks for the quick response, I did look at that article before running my script, however it errored on InvitedUserType command. My script is:


$invitations = import-csv c:\scripts\bulkinvite.csv
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "You are invited to the XXXXX organization."

foreach ($email in $invitations)
{New-AzureADMSInvitation `
-InvitedUserEmailAddress $email.InvitedUserEmailAddress `
-InvitedUserDisplayName $email.Name `
-InviteRedirectUrl `
-InvitedUserMessageInfo $messageInfo `
-SendInvitationMessage $false
-InvitedUserType "Member"


The result is the User is invited as Guest and I get the following output: 


InvitedUserType : Guest
Status : PendingAcceptance

-InvitedUserType : The term '-InvitedUserType' 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
At line:8 char:7
+ -InvitedUserType "Member"
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-InvitedUserType:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Thanks again,



This is a snippet from a script I used to invite > 5000 users to our tenant (and later to invite a few hundred more)


Up near the top of the script, I assign this (this is to make a member) - I don't think it is case sensitive



This code is used later (you can make an educated guess what the variables are from their names)

Watch for line wraps!

 if ([string]::isnullorempty($displayname)) {
 # if no displayname is specified, don't pass the parameter
  try {
   $result=New-AzureADMSInvitation -InvitedUserEmailAddress $upn -InviteRedirectUrl $url -SendInvitationMessage $false -InvitedUserType $B2Busertype -ea stop
  } catch {
  } # end try catch
 } else {
  try {

   $result=New-AzureADMSInvitation -InvitedUserEmailAddress $upn -InviteRedirectUrl $url -SendInvitationMessage $false -InvitedUserType $B2Busertype -InvitedUserDisplayName $displayname -ea stop
  } catch {
  } # end try catch
 } # end if [string] null displayname


Try changing "-InvitedUserType" to "-UserType". This should work fine.