How to hide and unhide all hidden contacts from GAL by using PowerShell script


How to hide contacts from GAL by using PowerShell

1.Follow the article to access Exchange Online through PowerShell:

Connect Windows PowerShell to the Service
http://help.outlook.com/en-us/140/cc952755.aspx

clip_image001

  1. To hide a contact from Global Address List, type the cmdlet bellow

Command:
Set-Mailbox -Identity jv@itprodev.onmicrosoft.com -HiddenFromAddressListsEnabled $true

clip_image002

  1. To check if your contact is hidden for the address list, type the command bellow

Command:
Get-Mailbox -Identity jv@itprodev.onmicrosoft.com | fl

clip_image003

How to unhide all hidden contacts from GAL by using PowerShell script

Summary
Contacts that are hidden from Global Address List (GAL) are not visible to Office 365 Exchange Online users. This article provides a method that unhide all hidden contacts from GAL by using PowerShell script.

1.Follow the article to access Exchange Online through PowerShell:

Connect Windows PowerShell to the Service
http://help.outlook.com/en-us/140/cc952755.aspx

clip_image001[1]

2. Export a list for contacts hidden from GAL by running the following cmdlet:

Command:
Get-Mailcontact -Filter {HiddenFromAddressListsEnabled -eq $true} | Select identity,alias,HiddenFromAddressListsEnabled | Export-Csv -Path C:\HiddenContacts.csv -NoTypeInformation

clip_image004

3. Unhide the contacts from C:\HiddenContacts.csv file by running the following cmdlet:

Command:
$users = import-csv C:\HiddenContacts.csv
Foreach($_ in $users) {Set-mailcontact $_.identity -HiddenFromAddressListsEnabled $false}

clip_image005

OR

Command:
Set-Mailbox -Identity jv@itprodev.onmicrosoft.com -HiddenFromAddressListsEnabled $false

clip_image006

More Information

Get-MailContact
http://technet.microsoft.com/en-us/library/bb124717.aspx

Set-MailContact
http://technet.microsoft.com/en-us/library/aa995950.aspx