Thursday, December 11, 2014

How to trigger re-indexing of updated user profiles in SharePoint Online

You asked for it, and I deliver an early Xmas present for your pleasure and enjoyment!

This script was made possible by the September 3rd release of the CSOM SDK which implements user profile write support. And DO NOT run it from a SharePoint Online Management Powershell, use a regular Powershell with no special cmdlets loaded. If not you get CSOM DLL hell.

Problem: You map an existing (or new) crawled property corresponding to a user profile property to a new managed property you want to use in search (phew). After the mapping, you wait and you wait and you wait (as you cannot start a full crawl yourself in SPO)… and you never get a value in your managed property. You curse some, you Google some, you post some questions in forums or Yammer. Then you go and edit your user profile in the SPO UI, wait some more.. and voila the value is there. You’re seriously baffled at the randomness and think to yourself

How the can I ask my 5,000 users to go edit their user profile to get that new property working in search??

(don’t worry - my script will help you out!)
Ok.. these are my findings as per December 10th 2014 (subject to change)
  • There are no full crawls executed on user profiles
  • User profiles are incrementally crawled at a 4 hour interval – Seen as low as 2 hours during the night and as high as 8h during the day
  • Working with search and user profiles in SPO will require patience – no way around it unless you hit the crawl schedule right on
So in order to trigger a re-index of a user profile you need to save it. What the script does is read out the SPS-Birthday field. Write a new random value to the field, and then re-write back the original value, that being a real date or blank. This has the effect of not messing with the data in the profile and triggering it to be re-index on the next user profile incremental crawl. If you have removed the SPS-Birthday field edit the script and use something else.

You still have to wait 2-8 hours for data to appear in the index, but it will appear - eventually.
Want the script….. head over to where you also will find my script to trigger content indexing in SPO.

You can find my post about re-indexing content  at