SOLVED

Bulk adding to Office 365 Groups with PowerShell

MVP

Hello, one of my customer actually trying to onboard every user in the organization to one Yammer Group which is linked to Office 365 Groups. We manage to automate onboarding for new users. But how to get current users, which are about 2500 people to this Group?

 

We try the simplest way with PowerShell and Add-UnifiedGroupLink cmdlet. Like Get all licensed MsolUser and each of them call Add-UnifiedGroupLink with Member link type with user UPN.

 

But we encounter the first problem: Office 365 start throttling this after 100 calls and start deny this requests. So we add Sleep to this script. But with that we encounter the second problem. Script is running and after time it get new auth prompt for MFA sign-in (about hour). Script continue and failing if someone does not looking to dialog and enter credentials fast enough.

 

Do you have some optimal way for this task? Bulk add about 2500 to Office 365 Group?

 

11 Replies

Office 365 groups have the limitation of 1000 users as members. So maybe you wanna split the group into 3 parts and start adding users. Please read more about limitations of O365 groups here:

 

https://support.office.com/en-us/article/Learn-about-Office-365-groups-b565caa1-5c40-40ef-9915-60fdb...

I understand that 1000 members are a soft limit as if it extends this number, it can get slower when accessing. But it will be one time actions and I mean that some people will leave this group.

That's not correct, AFAIK the number of members of a single Group is 2500
If you are getting throttled when adding 2500 users with Set-UnifiedGroup, I agree that splitting the users to be added into chunks could be a solution...the other way around could be to create a more sofisticad PowerShell script with some Re-Try logic so you can overcome the throttling

Hmmm... I think the official documented limit is still 1,000 (the same for Teams). Some work is ongoing to increase the limit. From a technical perspective, the issue is how many simultaneous connections can be supported by the group mailbox. This is clearly very important for Groups that use Exchange to store conversations, but not for groups that use Yammer. 

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.

best response confirmed by VI_Migration (Silver Contributor)
Solution

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!

Thanks for pointing to this. But we want a option to user to leave group and Dynamic Membership does not allow this because it add always user back. And also, it is in AAD Plan P1 and not all users are licensed for this.
Yes, I tried that, but not for 2500. Length of this is not parser correctly.
Thanks, this can do this work!
1 best response

Accepted Solutions
best response confirmed by VI_Migration (Silver Contributor)
Solution

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!

View solution in original post