A common situation in SharePoint is adding custom properties to a SharePoint profile. In an on-premises environment, it was very easy to link these properties to a property in AD. In SharePoint Online, you are not able to link these Azure AD properties. So how can we solve this?
There is a very simple solution for this in the Office Dev PnP PowerShell pack called ‘Set-PnPProfileProperty’.
This command sets any user profile property for the given user.
So how to set this up from start to finish.
Create a user profile property (optional)
This is an optional step because we can also use an existing property that is not connected to Azure AD.
Go to the SharePoint Online admin center and select ‘User Profiles’, then go to ‘Manage User Properties’ Here you can create a new property, the important part here is that you remember the value you added in the ‘Name’ field As you can see at the bottom of the page the section ‘Add new mapping’ is disabled.
Update the SharePoint property with AAD value
For this example, I use the field ‘Mobile phone’. In Azure AD the value of the mobile phone is stored in the field ‘Mobile’.
To copy the Azure AD value of ‘Mobile’ into the SharePoint field ‘CellPhone’, we need to do the following
Using custom Azure AD properties
In Azure AD you also can create or synchronize custom properties, you can access these properties with the command Get-AzureADUserExtension.
Make it a script
As you can see above it is very straightforward to copy an Azure AD property into a SharePoint Profile property. Now, all we need to do is create a script that will on a schedule and with the properties we need. the easiest way is to get all Azure AD users and loop thru them to set the desired SharePoint properties.