# All Office 365 Groups
#$groups = Get-UnifiedGroup

# One Office 365 group
#$groups = Get-UnifiedGroup -Identity "Group"

foreach ($group in $groups) {

Try {
# Get list of all members
$members = Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members
Write-Host "Members of ""$($group.DisplayName)"":" -ForegroundColor Green
Write-Host ($members | Format-Table | Out-String)

# Get list of all subscribers
$subscribers = Get-UnifiedGroupLinks -Identity $group.Name -LinkType Subscribers
Write-Host "Subscribers of ""$($group.DisplayName)"":" -ForegroundColor Green
Write-Host ($subscribers | Format-Table | Out-String)

# Subscribe all members not subscribed
Write-Host "Subscribing all members not currently subscribed..."
foreach ($member in $members) {
If ($member.Name -notin $subscribers.Name) {
Write-Host "Adding $($member.Name)."
Add-UnifiedGroupLinks -Identity $group.Name -LinkType Subscribers -Links $member.Name
} else {
Write-Host "$($member.Name) is already subscribed."
}
}

# Done!
Write-Host "Done!" -ForegroundColor Green
} Catch {
Write-Host "There was an error subscribing all users in ""$($group.DisplayName)""." -ForegroundColor Red
Write-Host $($Error[0].Exception) -ForegroundColor Red
Continue
}
}