Bulk Addition of External Users to Sharepoint online Site

As Technet Gallery is retiring so moving the code to Git Hub. (click below link, creating first link to my blog for those who are unfamiliar with github)https://techwizard.cloud/2019/06/26/bulk-addition-of-external-users-to-sharepoint-online-site/We got a  requirement to add hund

 
 
 
 
 
(0)
Add to favorites
Office 365
6/16/2020
E-mail Twitter del.icio.us Digg Facebook
  • How about adding a user to a SiteGroup?
    3 Posts | Last post December 27, 2019
    • So, the only issue I have with this is the user is not added to a SiteGroup.
      
      How do I add them to a SiteGroup, the other is harder to manage.
    • There is another approach, creating a azure ad group and populating that via script and inviting from there.
      
      New-AzureADMSInvitation  -InvitedUserEmailAddress vikas@labtest.com -InviteRedirectURL https://myapps.azure.com -SendInvitationMessage $false
      
      #Connect to AAD as admin prior to running
      
      $messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
        
      #Message Content
      $messageInfo.customizedMessageBody = "Please accept the invitation."
      
      #Security Group users are to be added to
      $group = get-azureadgroup -SearchString AZureADgrouptest
      
      #Address presented to the users in their welcome email
      $url = "https://company.sharepoint.com/sites/INtSite"
      
      #List of users to be imported
      $invitations = get-content .\users.txt
      
      #Add users as guests with Azure AD and then add them as members to the relevant security group
      $invitations | foreach-object { $result= New-AzureADMSInvitation `
            -InvitedUserEmailAddress $_ `
            -InviteRedirectUrl $url `
            -InvitedUserMessageInfo $messageInfo `
            -SendInvitationMessage $true
         $userid = $result.InvitedUser.Id
         Add-AzureADGroupMember -objectid $group.objectid -RefObjectId $userid
         write-host "Processing...$_" -foregroundcolor green
         }
    • This can be tackled another way by creating azure ad group and sending invitations from there
      
      New-AzureADMSInvitation  -InvitedUserEmailAddress vikas@labtest.com -InviteRedirectURL https://myapps.azure.com -SendInvitationMessage $false
      
      #Connect to AAD as admin prior to running
      
      $messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
        
      #Message Content
      $messageInfo.customizedMessageBody = "Please accept the invitation."
      
      #Security Group users are to be added to
      $group = get-azureadgroup -SearchString AZureADgrouptest
      
      #Address presented to the users in their welcome email
      $url = "https://company.sharepoint.com/sites/INtSite"
      
      #List of users to be imported
      $invitations = get-content .\users.txt
      
      #Add users as guests with Azure AD and then add them as members to the relevant security group
      $invitations | foreach-object { $result= New-AzureADMSInvitation `
            -InvitedUserEmailAddress $_ `
            -InviteRedirectUrl $url `
            -InvitedUserMessageInfo $messageInfo `
            -SendInvitationMessage $true
         $userid = $result.InvitedUser.Id
         Add-AzureADGroupMember -objectid $group.objectid -RefObjectId $userid
         write-host "Processing...$_" -foregroundcolor green
         }