Use PowerShell to hide mailboxes from the Global Address List in Office365
-
[Thanks to Greg Hall for assisting me with this!]
We recently underwent a corporate name change, which required us to migrate our users over to email addresses on the new domain.
Because most users still require access to their old account, I was unable to remove those mailboxes, which created confusion for the majority of users who pull from the Global Address List, which displays all mailboxes on our corporate Office365 account. Despite a change in the naming convention from <first initial><lastname> to <firstname>.<lastname>, folks were still sending plenty of email to old user mailboxes, thwarting our efforts to wean them away.
Initially I sought to segregate the old domain from the new using Address Book Policy, but found we had not defined certain parameters upon which New-AddressBookPolicy is dependent. So, moving away from that approach, and with the help of Greg Hall, I decided to simply hide the old mailboxes from the Global Address List - which worked perfectly. Here's how I did that . . .
Connect to Office365 using the Azure Active Directory Module, then input:
Get-User -Filter {Company -eq 'Microsoft'} | Get-Mailbox -resultsize unlimited | Set-Mailbox -HiddenFromAddressListsEnabled $true
And don't forget your Distribution Groups!
Export the list of group names to .CSV and input the following:
Get-Content -Path C:\LocationOf.CSV | Set-DistributionGroup -HiddenFromAddressListsEnabled $true
Bam. Done.
Of course, we had not defined the "Company" value in our users' Exchange properties, but I'll discuss using PS to edit Exchange properties in another post.
-
How does this effect the name.nk2 in Outlook? I'm guessing that people using Outlook and not OWA will still have the old addresses in name.nk2 and might still be sending email to the wrong address.
-
@Dashrender said:
How does this effect the name.nk2 in Outlook? I'm guessing that people using Outlook and now OWA will still have the old addresses in name.nk2 and might still be sending email to the wrong address.
I have always wanted a way to clean that file up remotely, but never wanted it enough to look into it.
-
@JaredBusch said:
@Dashrender said:
How does this effect the name.nk2 in Outlook? I'm guessing that people using Outlook and now OWA will still have the old addresses in name.nk2 and might still be sending email to the wrong address.
I have always wanted a way to clean that file up remotely, but never wanted it enough to look into it.
Frankly I'm more surprised that Outlook doesn't have some sort of tracking built into that file to watch for changes to the GAL and local address book for changes.
Changes like the OP mention have created nightmares for me as users are complaining that things don't work. Then I have to either delete whole file, or teach them how to manually edit the file to remove the old entry.
-
That's a good question!
I don't think the name.nk2 file draws from the GAL, rather it's populated through use over time. To that end, we simply asked users to delete their AutoComplete cache early on and start over (I know, some were rather distraught, including our technician who sat and cleaned up the HR Manager's list personally!).
I would definitely be curious to know if there's a way to simply edit the list, rather than manage it in broad strokes like delete, import and export. Though that doesn't seem to be the case.
-
@Dashrender said:
How does this effect the name.nk2 in Outlook? I'm guessing that people using Outlook and not OWA will still have the old addresses in name.nk2 and might still be sending email to the wrong address.
I'd say yes that is true.
However I am of the understanding that the name.nk2 files has been retired in Office 2013 and forward.
Not something I've followed or dev'ed into though.
-
Well the name.nk2 file itself might be retired, but the autocomplete listings are still there and are not fixed when someone changes addresses.
I had this problem last year in Outlook 2013
-
@Dashrender said:
Well the name.nk2 file itself might be retired, but the autocomplete listings are still there and are not fixed when someone changes addresses.
I had this problem last year in Outlook 2013
They only way to fix that would be to clear the auto complete list. That's solely based on the most common emailed addresses. It's per user and doesn't store on exchange in anyway (and isn't sync with OWA, OWA uses it's own list)