Hide O365 Groups from Outlook

If you’ve got Office 365 Groups kicking about in your Outlook profile but you’d really rather not see them or have them there then use power shell to “Hide” them.

There are two ways to “Hide” an Office 365 group; 1) from the GAL or 2) from the Exchange Client.

First, you will need to download the latest Exchange Online Power Shell module. You can get this from your Exchange Admin Center in Office 365 -> Hybrid then run the provided Function to connect to Exchange Online (see below)

NOTE: You need to download this module using “Internet Explorer or Edge”

#Modify the UPN only in Function

function Connect-EXOPSSession {

param(
# Connection Uri for the Remote PowerShell endpoint
[string] $ConnectionUri = ‘https://outlook.office365.com/PowerShell-LiveId’,

# Azure AD Authorization endpoint Uri that can issue the OAuth2 access tokens
[string] $AzureADAuthorizationEndpointUri = ‘https://login.windows.net/common’,

# User Principal Name or email address of the user
[string] $UserPrincipalName = ‘[email protected]’,

# PowerShell session options to be used when opening the Remote PowerShell session
[System.Management.Automation.Remoting.PSSessionOption] $PSSessionOption = $null,

# User Credential to Logon
[System.Management.Automation.PSCredential] $Credential = $null
)

$modules = @(Get-ChildItem -Path “$($env:LOCALAPPDATA)\Apps\2.0” -Filter “Microsoft.Exchange.Management.ExoPowershellModule.manifest” -Recurse )
$ModulePath = Join-Path $modules[0].Directory.FullName “Microsoft.Exchange.Management.ExoPowershellModule.dll”
# $ExoPowershellModule = “Microsoft.Exchange.Management.ExoPowershellModule.dll”;
# $ModulePath = [System.IO.Path]::Combine($PSScriptRoot, $ExoPowershellModule);

$global:ConnectionUri = $ConnectionUri;
$global:AzureADAuthorizationEndpointUri = $AzureADAuthorizationEndpointUri;
$global:UserPrincipalName = $UserPrincipalName;
$global:PSSessionOption = $PSSessionOption;
$global:Credential = $Credential;

Import-Module $ModulePath;
$PSSession = New-ExoPSSession -UserPrincipalName $UserPrincipalName -ConnectionUri $ConnectionUri -AzureADAuthorizationEndpointUri $AzureADAuthorizationEndpointUri -PSSessionOption $PSSessionOption -Credential $Credential

if ($PSSession -ne $null) {
Import-PSSession $PSSession -AllowClobber

}
}

Once connected to Exchange Online run the following to “hide” a single group

Connect-EXOPSSession

Get-Unifiedgroup -identity “Group1” | Set-Unifiedgroup “Group1” -HiddenFromExchangeClientsEnabled

Check that the group is now hidden

Get-unifiedgroup -identity “Group1” | select DisplayName,Hidden*

This method can also be used to hide batches of groups from Exchange Clients using a CSV file OR you can also hide all groups entirely from the GAL with a one line powershell

Connect-EXOPSSession

Get-Unifiedgroup | Set-Unifiedgroup -HiddenFromAddressListsEnabled $True

Happy Hiding!