# Office 365 – msExchHideFromAddressLists does not synchronize with Office 365

In my life I’ve deployed multiple Office 365 tenants connected with Active Directory and I’ve been synchronizing msExchHideFromAddressLists field from…

blog

24 Mar 2020 pl

![Office 365 – msExchHideFromAddressLists does not synchronize with Office 365](/wp-content/uploads/2020/03/img_5e66909e8c4c3.png)

[Zobacz obrazy (6)](#pf-content-image-1-0)

In my life I've deployed multiple Office 365 tenants connected with Active Directory and I've been synchronizing **msExchHideFromAddressLists** field from Active Directory to **HiddenFromAddressListsEnabled** in Azure AD without any issues. Recently I was notified that **msExchHideFromAddressLists** is not getting properly synchronized and surely enough the issue was that **Exchange hybrid deployment** was not checked.

[!\[Opcje dodatkowe Azure AD Connect z włączonym Exchange hybrid deployment\](/wp-content/uploads/2020/03/img_5e66909e8c4c3.png)](/wp-content/uploads/2020/03/img_5e66909e8c4c3.png)

So you tick the checkbox do Initial sync and you're done.

```powershell
Start-ADSyncSyncCycle -PolicyType Initial
```

Except that it doesn't work.

```powershell
get-mailbox -Identity 'bartosz.klys@evotec.ooo' | Format-List *HiddenFromAddressListsEnabled*
```

Command above would still show **FALSE** for **HiddenFromAddressListsEnabled**. Quick check AD side and msExchangeHideFromAddressLists is **Enabled**.

```powershell
Get-ADUser -filter { userprincipalname -eq 'bartosz.klys@evotec.ooo' } -Properties msExchHideFromAddressLists
```

[!\[Wynik PowerShell pokazujący msExchHideFromAddressLists ustawione na True\](/wp-content/uploads/2020/03/img_5e71ecb27dc3d.png)](/wp-content/uploads/2020/03/img_5e71ecb27dc3d.png)

So what to do?

### 💡 How to make sure HiddenFromAddressListsEnabled works as expected?

To make sure hidding mailboxes from **Global Address List (GAL)** works correctly you should verify few things

- 💡 Active Directory has Exchange Extended Schema – this can be done by downloading Exchange 2016 CU15 or similar and executing **Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareSchema** command

[!\[Instalator Exchange Server przygotowujący schemat Active Directory\](/wp-content/uploads/2020/03/img_5e791d91ca121.png)](/wp-content/uploads/2020/03/img_5e791d91ca121.png)

- 💡 Exchange hybrid deployment is selected in Azure AD Connect

[!\[Opcje dodatkowe Azure AD Connect z włączonym Exchange hybrid deployment\](/wp-content/uploads/2020/03/img_5e66909e8c4c3.png)](/wp-content/uploads/2020/03/img_5e66909e8c4c3.png)

- 💡 Run Initial Synchronization after any change of configuration

```powershell
Start-ADSyncSyncCycle -PolicyType Initial
```

- 💡 Update msExchHideFromAddressLists for each user that you want to hide from GAL (set TRUE as value)
- 💡 Refresh directory schema with any change to AD Schema

[!\[Ekran Dodatkowe zadania Azure AD Connect z zaznaczonym Refresh directory schema\](/wp-content/uploads/2020/03/img_5e6690ea94af2.png)](/wp-content/uploads/2020/03/img_5e6690ea94af2.png)[!\[Strona Refresh Directory Schema w Azure AD Connect\](/wp-content/uploads/2020/03/img_5e6691311107a.png)](/wp-content/uploads/2020/03/img_5e6691311107a.png)

All the steps above I've done and shown that it's not working. The final and **often omitted **step is what also needs to be set for each user

- 💡 Update **mailNickName** attribute to **proper**, **non-empty** value

Not so obvious right? Of course, if you have local **Exchange**, it would be done automatically, but most small Clients don't have resources to run an additional machine. While it's technically not a supported scenario, it's how most **SMB Clients** are working. Now we just need to fix all our users that have **Mail** field set, and are missing **MailNickName**.

```powershell
$WhatIf = $true
$Forest = Get-ADForest
foreach ($Domain in $Forest.Domains) {
    $Users = Get-ADUser -Filter { Mail -like '*' -and MailNickName -notlike '*' } -Properties mailNickName, mail,msExchHideFromAddressLists -Server $Domain
    $Users | Format-Table -AutoSize Name, SamAccountName, DisplayName, Mail,mailNickName, Enabled, msExchHideFromAddressLists,DistinguishedName
    foreach ($_ in $Users) {
        Set-ADUser -Identity $_ -Replace @{mailNickname = $_.SamAccountName } -Server $Domain -WhatIf:$WhatIf
    }
}
```

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Inspect and convert mixed Office archives with PSWriteOffice](/blog/inspect-and-convert-mixed-office-archives-pswriteoffice/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:0E36526E0F5F17F24EE0DEE7DC5B41B93D3EE106B004AAE490805CE5048BD075 -->
