We will learn to force sync an Azure Active Directory or Microsoft Intra ID user in Dynamics 365 using PowerShell script. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Platform.
In Dynamics 365 Customer Engagement, user and team management encompasses the creation of users & profiles. A user within Dynamics 365 CE refers to an individual employed by a business unit utilizing the platform. Each user is assigned a user account and is required to be affiliated with a singular business unit. This affiliation dictates the specific customer data accessible to the user.
The user’s account comprises details like telephone numbers, email address, and a link to the user’s manager. Every user possesses privileges and rights to administer their personal settings. Each user aligns with a corresponding user in the Active Directory specific to the organization.
When you create a user, you must assign the user to at least one security role. Even if the user is part of a team that has assigned roles, the user should be assigned to a role.
When we create an user in Azure AAD / Entra ID, they are not synced to Dynamics 365 CE in Realtime. We can use the below solution to force sync users from Azure AAD / Entra ID to Dynamics 365 in realtime.
Syncing & creating users in Dynamics 365 with PowerShell
The below given solution enables you to sync users in Dynamics 365 Customer Engagement in a synchronous fashion (Realtime).
Installing PowerShell for Power Platform Administrators
Follow the below procedure to install PowerShell for Power Platform administrators in your local machine.
- Run PowerShell as an administrator.
- Import or update the necessary module by using one of the following commands:
PowerShell Command: Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
- Run the below command if you do not have Administrator rights in your local machine.
PowerShell Command: Save-Module -Name Microsoft.PowerApps.Administration.PowerShell -Path Import-Module -Name Microsoft.PowerApps.Administration.PowerShell
- If you receive a prompt to confirm the modification to the InstallationPolicy value of the repository, acknowledge [A] Yes to All modules by entering ‘A’ and pressing Enter for each module.
PowerShell scripts for creating user in Dynamics 365 CE
Below is the PowerShell scripts which you can use for force synchronizing users in Microsoft Dynamics 365 Customer Engagement.
Add-AdminPowerAppsSyncUser -EnvironmentName [Guid] -PrincipalObjectId [Guid]
In this demonstration, we will forcefully sync a newly created user named “Pooja Prashant Tirlotkar” in Dynamics 365.
- Configure the PowerShell cmdlet as per the instruction given above.
- Collect the environment ID and user’s principal ID from Power Platform Admin portal & Microsoft Admin Portal.
- Run the PowerShell command as given in the above instruction.
- Open your Dynamics 365 CE environment, and you will observe that a new user is automatically created over here.
In conclusion, force syncing users in Dynamics 365 is a crucial administrative action that ensures the accurate and up-to-date representation of user information within the system. By triggering a synchronization process, administrators can promptly reflect changes in user details as per the requirement.