Using Configure-EnterprisePartnerApplication.ps1 in a multi domain controller environment

You use the Configure-EnterprisePartnerApplication.ps1 to create partner application to be used for OAuth with SharePoint 2013 and Lync 2013. The script creates a mail user and assigns management roles to that mail user.

When running the script in an environment with multiple Active Directory domain controllers in the site, you might see the script failing. It happens because it creates the user on one domain controller and then search for it using another domain controller and the search fails.

Creating Partner Application <Lync Enterprise-7da0c6999277459ca10385cb7870b005> using metadata <https://lync.contoso.dk/metadata/json/1>.

 

Created Partner Application <Lync Enterprise-7da0c6999277459ca10385cb7870b005>.

 

Creating User <Lync Enterprise-ApplicationAccount> for Partner Application.

 

Couldn't find object "contoso.dk/Users/Lync Enterprise-ApplicationAccount". Please make sure that it was spelled correctly or specify a different object.

+ CategoryInfo : NotSpecified: (:) [Set-Mailbox], ManagementObjectNotFoundException

+ FullyQualifiedErrorId : A01C78F0,Microsoft.Exchange.Management.RecipientTasks.SetMailbox

+ PSComputerName : e15.contoso.dk

 

Created User <contoso.dk/Users/Lync Enterprise-ApplicationAccount> for Partner Application.

 

Assigning role <UserApplication> to Application User <contoso.dk/Users/Lync Enterprise-ApplicationAccount>.

 

Couldn't find a user with the identity "contoso.dk/Users/Lync Enterprise-ApplicationAccount".

+ CategoryInfo : NotSpecified: (:) [New-ManagementRoleAssignment], ManagementObjectNotFoundException

+ FullyQualifiedErrorId : 55267DAC,Microsoft.Exchange.Management.RbacTasks.NewManagementRoleAssignment

+ PSComputerName : e15.contoso.dk

 

The solution is to use the –domaincontroller switch to Configure-EnterprisePartnerApplication.ps1 and specify a domain controller. The script will then use that domain controller for all its operations.