1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 } } |