Forum Discussion
Setting Azure B2B Users as Members via the invitation
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 userid@domain.co.uk | 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
- sabsyncCopper Contributor
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 https://myapps.azure.com `
-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
again.
At line:8 char:7
+ -InvitedUserType "Member"
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-InvitedUserType:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundExceptionThanks again,
Sabs
- CorsinoCopper ContributorTry changing "-InvitedUserType" to "-UserType". This should work fine.