How to remove an Address Book Policy with Powershell for Office365/Exchange On-Line

Yesterday I was playing with address book policies in Exchange On-line. After a while I wanted to delete a Address Book Policy (ABP) which I created (in this case the ABP is called svg-abp). But when I tried to remove it with the Powershell command: “Remove-AddressBookPolicy -Identity svg-abp” I was getting the error stated that there where still users connected to the ABP.


The next step was to identify which users where still connected to the ABP. The best Powershell command I had found was on Technet ( “Get-Mailbox | where $._AddressBookPolicy -eq “svg-ABP”}”. But this one will not work, there is a } at the end of the cmdlet. When you remove it, it will run:


So unfortunately this Powershell CMDlet does not work correctly. It is not showing any mailbox connected to the ABP. You need to use “Get-Mailbox | where AddressBookPolicy -eq “SVG-ABP””


So you now have the mailbox that is connected to the ABP SVG-ABP. But one drawback of this command is that you do not query the soft deleted users/mailboxes. If there are any users with that ABP connected, you still cannot delete the ABP. To list the soft deleted users/mailboxes where the ABP has been assigned you can use the powershell command: “Get-Mailbox -SoftDeletedMailbox | where AddressBookPolicy -eq “SVG-ABP””


So now you know which mailbox you need to give another ABP before you can remove the ABP. You can do this with the Powershell commando “Set-Mailbox -identity info_c43c66d4b5 -AddressBookPolicy “Redcoat-ABP”:


Now you are able to remove the ABP:


Do not forget to also delete the Offline Address Books (OAB), Address Lists (AL) and Global Address Lists (GAL) linked to the ABP.