Exchange Online: Subscribe Existing Members to Microsoft 365 Group Using PowerShell

Hi,

So I recently had a case whereby a user was leveraging Microsoft 365 Groups for Microsoft Teams voicemails, but only some of the users were being emailed. Upon carrying out a message trace and eDiscovery I could confirm that the some users were in fact, not being emailed. With no service issues currently raised for Exchange Online I assumed it wouldn’t be a service delivery issue and began investigating.

An (un)expected feature?

Firstly I found this article from Microsoft which appeared to confirm what I feared, this is a deliberate configuration from Microsoft 365 that Microsoft recommend the users control, this isn’t always ideal, especially when you’re not expecting this.

For years there have been posts such as this one asking if it is possible to subscribe all members to a group after creating one. Most of the time the answers have been the same, either follow the Microsoft article I linked to earlier, or once you enable the auto subscription function, remove and re-add all the users. Not ideal!

However, like most things within Microsoft 365, we can achieve what we need via PowerShell, even if the GUI doesn’t present us an option to change.

Subscribing New Users Automatically

Our first step to resolve this should be ensuring any new users get automatically added. We can run the following cmdlet to check what happens to new members:

Get-UnifiedGroup -Identity <Office365Group@domain.tld> | fl Identity, DisplayName, AutoSubscribeNewMembers

We then get the following output:

To enable automatic subscription of new members, run the following cmdlet:

Set-UnifiedGroup -Identity <Office365Group@domain.tld> -AutoSubscribeNewMembers

If we re-run our previous Get-UnifiedGroup cmdlet we’ll see this change has taken effect.

For completeness of information, should you require disabling the auto subscription for new members, you can run the following cmdlet:

Set-UnifiedGroup -Identity <Office365Group@domain.tld> -AutoSubscribeNewMembers:$false

Subscribing Existing Members

Okay, now our new members will be automatically subscribed, lets work through the existing members and get them subscribed. Again, PowerShell will be our friend for this.

We’ll be making use of the “Get-UnifiedGroupLinks” and “Set-UnifiedGroupLinks” cmdlets here. First, to see how many members we have within our Microsoft 365 Group:

Get-UnifiedGroupLinks -Identity <Office365Group@domain.tld> -LinkType Members

You should be able to see from the image above, I have 14 members within my group. Now lets see how many subscribers I have with the below cmdlet:

Get-UnifiedGroupLinks -Identity <Office365Group@domain.tld> -LinkType Subscribers

Well, that’s not good, only 2 of my 14 members are subscribed to receive emails! Lets fix this now! To do so, just run the following cmdlets:

$Group = Get-UnifiedGroup -Identity <Office365Group@domain.tld>
$Members = Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members
$Subscribers = Get-UnifiedGroupLinks -Identity $group.name -LinkType Subscribers
foreach ($Member in $Members) {If ($Member.Name -NotIn $Subscribers.Name) { Add-UnifiedGroupLinks -Identity $Group.Name -LinkType Subscribers -Links $Member.Name}}

Okay, now lets run our previous Get-UnifiedGroup cmdlet where we wanted to see just our subscribers!

Much better!

I’ve got a lot of groups to go through, how can I process them all quickly?

If you need to process all of your groups you can run the following cmdlets to set the automatic subscription for new users and subscribing all existing users as follows:

Enable Automatic Subscription For All Existing Microsoft 365 Groups:

Get-UnifiedGroup | Set-UnifiedGroup -AutoSubscribeNewMembers

Subscribe All Existing Members of All Microsoft 365 Groups:

$Groups = Get-UnifiedGroup
foreach ($Group in $Groups){
$Members = Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members
$Subscribers = Get-UnifiedGroupLinks -Identity $group.name -LinkType Subscribers
foreach ($Member in $Members) {If ($Member.Name -NotIn $Subscribers.Name) { Add-UnifiedGroupLinks -Identity $Group.Name -LinkType Subscribers -Links $Member.Name}}}

Conclusion

This should help most people with their needs, others may need to make this a bit more bespoke and import a large list of groups, but not manipulate all of them, you can achieve this with a CSV file and processing the list based on that, but that’s out of scope for this post! Hope this helps.

By micoolpaul

Technical Consultant at Nexus Open Systems. Focusing on Veeam, VMware & Microsoft Productivity and Infrastructure stacks.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: