Forum Discussion
Bulk adding to Office 365 Groups with PowerShell
- Sep 22, 2017
I just did this:
[PS] C:\> $Users = (Get-Recipient -RecipientPreviewFilter {RecipientTypeDetails -eq "UserMailbox" -and CustomAttribute3 -ne "N"}
[PS] C:\> Add-UnifiedGroupLinks -Identity O365Group -LinkTypeMembers -Links $Users.Name
This creates an array of all user mailboxes in the tenant that are not marked with a value in one of the customized attributes. I then use the array as input to Add-UnifiedGroupLinks, which added all (30) the users to the group.
I forgot that I had this example in Chapter 15 of the Office 365 for IT Pros ebook... PowerShell is great!
Instead of issuing a separate Add-UnifiedGroupLinks call for every licensed user, you could try grabbing a batch of users and combining them into a single Add-UnifiedGroupLinks call.
Add-UnifiedGroupLinks - Id GroupName -LinkType Member -Links Member1, Member2, Member3, Member4...
This would be much more efficient than adding one member at a time. I just ran a test and was able to add 12 members in a single operation.