demystifying User Profile picture sync in #Office365

User profile pictures is one of the key factor for collaboration with in Office365. User Pictures are surfaced on almost of the service with in Office 365 such as Exchange Online, SharePoint Online, Lync (Skype) Online as well their client applications such as Outlook, Office, Skype for business etc.

To provide seamless experience to the end users its important to understand how it pictures are synchronized internally with in Office 365, Some notable issues and possible ways of automation.

Typical User Profile Sync process:

Most common scenario is of user profile picture sync process is through DirSync. When Dirsync completes the Synchronization to Azure AD, EXO gets a copy from AzureAD then SPO gets a copy from EXO. Though Outlook/Lync online is updated instantly, SPO might take up to 72 hours to show the picture.  EXO uses single image throughout the application. But SPO online uses three different images of single single user profile. For an example SPO ribbon uses a small image where as MySite/Delve uses a larger image.  So the User profile Service takes extra time to scale the images.

SPO Image variations:
200px * 200 px

72px * 72px

48px * 48px


Its not always a smooth ride from DirSync to SPO. If the process fails at any of the three stages, user’s may not get a profile pic in SPO. Here are some of the scenarios

  • AD images greater than 10KB or with wrong dimensions
  • Licensed for SPO but not EXO
  • Poor picture resolution in SPO Delve/Mysites


I often faced scenarios where the customers would require their pics across all the services in Office 365 in the next day. In those cases PowerShell is your friend. Below script uses Set-UserPhoto to upload high resolution pictures to EXO and ProfilePictureUploader project from Office365 Developer Patterns and Practices (PNP) to upload the Profile pictures to SharePoint Online.


Now the only thing you needed is the high resolution images on your local file share in “Firstname Lastname.JPG” format and configure the variables. This script

  • Saves the credentials securely for future use
  • Generates the UPN values from the User profile picture names. (Eg: John Doe.jpg =>
  • Uploads the image to Exchange online
  • Scales the source image small (48px), medium (72px), Large (200 PX) images and uploads to SharePoint online
  • Archive the processed images

How to run this:

Download the Zip file and Configure the below values in configuration.xml

Configuration values:

For details please refer ProfilePictureUploader project

  1. tenantName: eg:
  2. pictureSourceCsv: C:\Scripts\UpdateProfilePics\Release\userlist.csv
  3. thumbs upload3Thumbs: True
  4. additionalProfileProperties:
  5. logFile path:“C:\Scripts\UpdateProfilePics\Release\log.txt”
  6. uploadDelay:500
  7. credFile:Location to store the O365 credentials
  8. psLogfile: Location to store PS logs
  9. (Global admin)
  10. localPhotosFolder:\\fs.corp.local\Public\Employee Photos\O365\ready
  11. localPhotosArchiveFolder:\\fs.corp.local\Public\Employee Photos\O365\archive
  12. domainName:spbreed
  13. exeLocation:C:\Scripts\UpdateProfilePics\Release (Location of ProfilePictureUploader Binaries)

Troubleshooting tips:

  •  O365AdminAccount should be a Office 365 global administrator
  • SetExecutionPolicy RemoteSigned should be enabled
  • Powershell modules for Azure AD and MSOL Sign in assistant should be installed.


17 thoughts on “demystifying User Profile picture sync in #Office365

    • Replace GetEmail function with below code

      function GetEmail

      $temp = ($name.Substring(0, $name.IndexOf(‘.’))).split(‘ ‘)
      $emailDomain = “@” + $domainName + “.com”
      $email = $temp[0]+$temp[1].Substring(0,1)+ $emailDomain
      LogWrite (“**– Generated $email from $name –*”)
      return $email


  1. thank you, but getting the following error 😦

    Script tmp_0dcewjet.xlb {Add-AvailabilityAddressSpace, Add-DistributionGroupMember, Add-MailboxFolderPermis…

    15/07/2016 12:37:47 **– Uploading Profile Picture started for StuartC.JPG.Name –*

    15/07/2016 12:37:47 You cannot call a method on a null-valued expression.

    15/07/2016 12:37:47

    15/07/2016 12:37:47 InvalidOperation: (:) [ForEach-Object], RuntimeException

  2. Is it Posible to use this tool for a German Office 365 Tenant? In that case the folder for the Profile Pictures is “Profilbilder” instead of ” Profile Pictures”

  3. Hi , I used this code to upload few of my user pictures to Sharepoint Online. After running the script I can see the images of the users in their respective Delve Site. How ever for some of the users in the log I am seeing the below error message. You have any idea what might be the issue.

    User Error: Failed to upload thumbnail picture to SPO for Cannot access a closed Stream.

  4. Pingback: I’m not “Doughboy”, I’m a real person (and it’s not Yammer’s fault) |

  5. Hi ! I’m trying your solution but I have an error with the connection to profile web service “Error initiating connection to profile web service in SPO Value cannot be null. Parameter name: cookieHeader” Can you help me ?

    • Sorry I find my error. But now I have a new one. When it try to upload the pictures, I have this error :
      ==> Uploading threes image to SPO, with resizing
      ==> Uploading small image to /User Photos/Profile Pictures/YBenhammada_SThumb.jpg
      ==> User Error: Failed to upload thumbnail picture to SPO for YBenhammada The remote
      server returned an error: (409) Conflict.

      Can you help ?

      Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s