Apr 08 2019
03:29 AM
- last edited on
Jan 14 2022
04:46 PM
by
TechCommunityAP
Apr 08 2019
03:29 AM
- last edited on
Jan 14 2022
04:46 PM
by
TechCommunityAP
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
Apr 08 2019 03:35 AM
Apr 08 2019 03:56 AM
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
Thanks again,
Sabs
Apr 26 2019 05:23 AM
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
$B2Busertype="member"
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 {
$goterr=1
} # end try catch
} else {
try {
$result=New-AzureADMSInvitation -InvitedUserEmailAddress $upn -InviteRedirectUrl $url -SendInvitationMessage $false -InvitedUserType $B2Busertype -InvitedUserDisplayName $displayname -ea stop
} catch {
$goterr=1
} # end try catch
} # end if [string] null displayname
Jul 18 2019 09:52 AM