Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

13 thoughts on “SharePoint Online: Sync User Profile Property from Azure AD using PowerShell

  • May 28, 2021 at 6:30 AM

    I am getting error while doing it for all users – Set-PnPUserProfileProperty : This operation requires you to be managing your own data or have administrator privileges. I am sharepoint administrator already

    Reply
  • January 6, 2021 at 2:41 PM

    Running this as a global admin and sharepoint admin and receive the following;

    Set-PnPUserProfileProperty : Access denied. You do not have permission to perform this action or access this resource.

    Any ideas why this would be the case?

    Reply
  • November 19, 2020 at 10:29 PM

    Salaudeen, I tried the first script and ran into a few problems. First, it looks like it needs t be “mobile” and not “MobilePhone”. I made that change and got a bit further but then I get an error “Error Synching User Profile Property! Exception calling “.ctor” with “2” argument(s): “The ‘username’ argument cannot be null.
    Parameter name: username”. I am NOT a wiz with Powershell or any of the rest of this. Can you point me in right direction?

    Reply
  • August 25, 2020 at 5:58 PM

    Thanks Salaudeen, Good article. I’m hoping this has moved me forward very quickly on a bit of project work, with the introduction of a few improvements to allow for script #2 to update multiple properties per user account.

    Reply
  • May 20, 2020 at 8:58 PM

    Can I use this script to sync “Country or Region” from Azure AD to SharePoint user profile property? Just change these values?
    $ADPropertyName = “Country”
    $SPOPropertyName = “Country”

    second question. I assumed I have to create a custom managed property in SharePoint called “Country”?

    Reply
    • August 24, 2020 at 3:12 PM

      Script works great for all users until it ran into an error on a user that doesn’t have user profile. The script stop after it. How do I modify the script to ignore the error and continue to the next user?

      error”Error Updating User Profile Property! Cannot index into a null array.”

      Reply
  • April 19, 2020 at 8:57 PM

    Hi,
    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?

    Reply
    • April 20, 2020 at 11:14 AM

      Yes! It works for any Azure AD Properties, Including Custom user profile properties from AD!

      Reply
    • July 28, 2020 at 11:58 PM

      Great post Salaudeen!

      So to utilise extended fields from AD/AAD, would this mean it’s just a case of defining the variables for the customer fields? and then a foreach for each of the custom values?

      $ADPropertyName = “MyCustomValue”
      $SPOPropertyName = “MyCustomValue”

      Reply
    • July 29, 2020 at 9:02 PM

      Yes, That’s right! Also make sure your extended property is mapped from AD to AAD in AD Sync tool.

      Reply
  • April 19, 2020 at 8:54 PM

    Hi, Does it work for a custom property in On-Premise AD which is synced to Azure AD ?
    In another words, If we create a custom user profile property in User profile application within SPO, with the above script can we sync any corresponding custom attribute from Local Ad to Azure AD to the Custom User Profile property?

    Reply

Leave a Reply