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.

4 Responses

  • Roby Skariah

    Can a custom property in On-Premise AD be synced to Azure AD and then synced to a Custom User profile property in SPO, using this approach? Or does it only work for standard properties of AD?
    I am referring to a custom property that is to be created in local AD as well in Azure AD before being synced to SPO user profile.

    • Hello Roby,

      This is possible, Just add the property into the sync and you will find it in $user.ExtensionProperty.extension_[SomeGuid]_[propertyName].


  • Great Article!

    I’m trying to do the same thing that Roby mentioned. My Active Directory custom attribute has been synced to Azure AD. For instance, my extension property shows up as:
    PS H:\> Get-AzureADApplication | Get-AzureADApplicationExtensionProperty

    ObjectId Name TargetObjects
    ——– —- ————-
    xxxxx-f529-445c-92ed-96f49611169f extension_xxxx13c7d34442c952511aa071fa3a5_ipPhone {User}

    What should the value be for the custom attribute?
    $User = Get-AzureADUser -SearchString “user@mydomain.com”
    Set-PnPUserProfileProperty -Account $user.UserPrincipalName -PropertyName “ipPhone” -Value $extension_xxxx13c7d34442c952511aa071fa3a5_ipPhone

    I have tried the above but the value is not displayed on my ipPhone property

    • Hello Brandon,

      You are missing a part in the value
      You need to add $user.ExtensionProperty. in front of the extensionattribute.
      So the total should be like:

      $User = Get-AzureADUser -SearchString “user@mydomain.com”
      Set-PnPUserProfileProperty -Account $user.UserPrincipalName -PropertyName “ipPhone” -Value $user.ExtensionProperty.extension_xxxx13c7d34442c952511aa071fa3a5_ipPhone


Leave a Reply to Arjan Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.