Skip to content

How to hide Teams groups visibility from Outlook lists?

Whenever you create a team in Microsoft Teams, it’ll also automatically create a group that also contains an email distribution list. This can lead to confusing situations if an organization is also using “traditional” distribution lists.

My client requested to hide all the Teams lists in Outlook, and I found this post useful to do that with minor tweaks:

https://office365itpros.com/2021/07/08/how-hide-teams-enabled-groups-from-exchange-online/

I never remember what to do with PowerShell by heart as it is not my daily tool to use. So I figured out that first, we need to connect to the correct organization with PowerShell before we are able to run those commands mentioned in the blog post.

So I ran the following steps first (admin mode):

Install-Module ExchangeOnlineManagement

 Connect-ExchangeOnline 

–Sign in —

Then, I ran the script successfully:

 $HiddenGroups = 0Write-Host “Finding team-enabled Microsoft 365 Groups and checking for any which are visible to Exchange clients”[array]$Groups = Get-UnifiedGroup -Filter {ResourceProvisioningOptions -eq “Team”} -ResultSize Unlimited# Reduce to the set visible to Exchange clients[array]$Groups = $Groups | ? {$_.HiddenFromExchangeClientsEnabled -eq $False} 

# Process the remaining groups and hide them from ExchangeIf ($Groups.Count -ne 0) {  ForEach ($Group in $Groups) {     Write-Host “Hiding” $Group.DisplayName     $HiddenGroups++     Set-UnifiedGroup -Identity $Group.ExternalDirectoryObjectId -HiddenFromExchangeClientsEnabled:$True -HiddenFromAddressListsEnabled:$True  }} Else { Write-Host “No team-enabled Microsoft 365 Groups are visible to Exchange clients and address lists” } 

Write-Host (“All done. {0} team-enabled groups hidden from Exchange clients” -f $HiddenGroups) 

Note: if you try to copy and paste the code from the Office365itpros post, there’s quite likely a syntax error with the Else line statement, I’ve fixed that here. 

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *