Posted in : Exchange, Office 365

1 year ago

Introduction

A lot of people are using the Address Book in Outlook or their web mail to find people, but sometimes it can be a hard time filtering on company or departments.
Therefore we will go thru how to create custom Address Lists, and in this case only users with a mailbox that have something typed into the Office-attribute will appear in these lists.

Connect with PowerShell to Exchange Online with MFA
In this case we are working against an Exchange Online with Multi Factor and since Address Lists can’t be managed in the GUI, we have to use PowerShell to do the work.
Before we even fire up PowerShell there is a Role-setting we need to change to be able to use the correct PowerShell cmdlet (AddressList).
 
Set AddressList Role

  • Open your Exchange Admin Center, go to permissions in the left pane and then admin roles. Open the group you would like to give the AddressList-role to, in my case I choose Organization Management.
  • Add the Address Lists-role and the members that should have access to these permissions.

Changes like these may take a while to activate so have a little patience.
 
Admin Roles
PowerShell
Once you have the correct permissions you are ready to begin.

  • Open PowerShell as an Administrator.
    PowerShell Administrator
  • Connect to an Exchange Online with MFA.
    cd "C:\Program Files\internet explorer"
    .\iexplore.exe https://cmdletpswmodule.blob.core.windows.net/exopsmodule/Microsoft.Online.CSE.PSModule.Client.application
    Connect-EXOPSSession -UserPrincipalName USERNAME@DOMAIN.onmicrosoft.com
  • Once you are logged in via PowerShell you can start off by running Get-AddressList to get an overview of your current Address Lists.
    Get-AddressList

Now let’s say that our company name is Cool Company and we have 4 different offices that we want to categorize into address lists:
Gothenburg
Stockholm
Malmö
Luleå
The first thing we have to do is to create an empty list that is named after our company.

New-AddressList -Name 'Cool Company'

 
In the next step we will start to create address lists for each office and put them under our company list that we just created.

New-AddressList -Name 'Gothenburg' -Container "\Cool Company" -RecipientFilter {((RecipientType -eq "UserMailBox") -and (Office -eq 'Gothenburg'))}

Repeat this step for each office.
If we run the Get-AddressList-command we can now see our newly created lists:
AddressList
Now you could believe that we are done by now, but in fact you won’t be able to see anyone in the lists right now.
This is due to the fact that the users need to be edited/updated in their profile since we are running Exchange Online, or else they won’t be visible in your newly created list.
In this case I just go to one of my users Azure-AD profile and enter Gothenburg into his Office-attribute, but you might as well run a PowerShell-command that configures any attribute on all of your users to update them.
User Management
Now if we head over to one of our users, open Outlook and have a look in their Address Book we should now be able to see our changes.
You might have to update the address book in the Outlook-client.
In this case I’ve opened the Gothenburg-list and as you can see our user named Andreas is now visible since the users Office-attribute is set to Gothenburg.
Address Book
If you have any questions regarding the setup please leave a comment down below.
 
Sources
Microsoft Docs – Manage address lists in Exchange Online
 

Tags : Address List, AddressList, Exchange Online, M365, Mail, Microsoft365, O365, Office365, PowerShell, Role

Add comment

Your comment will be revised by the site if needed.