“Exception has been thrown by the target of an invocation” is an error you can see in Office 365 Rich Coexistence when you are first configuring the settings. There are other errors that can occur which also are the result of the same issue, for example I have seen “Error when getting bip rule” and “The user quota was exceeded“.
The error is due to the hydration status of your tenant at Office 365. Each Office 365 tenant is not “hydrated” by default. Hydration is the adding of lots of settings in the Exchange Online directory service per tenant – by default lots of tenants do not need these settings and so rather than creating the settings per tenant, each tenant shares these common settings.
To enable your own Transport Rules, preset security policies, Free/Busy Rich Coexistence and custom RBAC settings require that all the “common” settings in the directory are copied to the tenants area of the directory. To do this means you need to run the Enable-OrganizationCustomization cmdlet in remote PowerShell to Exchange online.
Once this is done the GUI will create RBAC, rules, free/busy etc. without throwing Exception has been thrown by the target of an invocation error.
The exact steps to perform on your Office 365 tenant before configuring RBAC, rules or coexistence are as follows:
- Start the Windows Powershell
- [once only] Import-Module ExchangeOnlineManagement
Article updated over ten years later on Dec 2nd 2021 as this is still an issue in Exchange Online!