Kirk Liemohn is a Principal Software Engineer in the Transformation Practice at ThreeWill. He has spent nearly a decade helping clients transform and migrate their content from one platform to another (typically to Microsoft 365) with a focus on the more complex scenarios. Prior to his transformation focus, Kirk led several key SharePoint integrations at ThreeWill including Jive, Polycom, and Confluence.
Four years ago, I was wrestling with profile pictures in Microsoft 365. In a post, I discussed how the profile image can surface in many applications in Microsoft 365 and that it can be inconsistent between those applications.
Unfortunately, after four years there are still inconsistencies and issues. Nowadays I’m doing a lot of migrations, many of which are from Jive to SharePoint. We can migrate Jive profile pictures to Microsoft 365, but the process is far from perfect. Here’s the strategy we take:
- Download the profile pictures from Jive. Our migration utilities take care of this for us.
- Run the Set-UserPhoto PowerShell cmdlet for each user.
- Wait 72 hours.
- Run custom code that uploads the profile image to a special “User Photos” library.
Wait another 72 hours (just in case).UPDATE: Test results using a clean browser (clear the cache)
Let’s dive into the details…
Step #2 is a simple PowerShell script:
[powershell]Write-Host "Enter SharePoint migration account credentials"
$creds = Get-Credential
# Note: the connection URI is different for Exchange Online vs. Exchange on-prem
# Exchange Online: https://outlook.office365.com/powershell-liveid
# Exchange On-prem: https://ps.outlook.com/powershell/
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $creds -Authentication Basic -AllowRedirection
Set-UserPhoto "<user-id1>" -PictureData ([System.IO.File]::ReadAllBytes("<path-to-image1>")) -Confirm:$false
Set-UserPhoto "<user-id2>" -PictureData ([System.IO.File]::ReadAllBytes("<path-to-image2>")) -Confirm:$false
Set-UserPhoto "<user-id3>" -PictureData ([System.IO.File]::ReadAllBytes("<path-to-image3>")) -Confirm:$false
Of course, those last three lines are really thousands of lines that we generate. This by itself is fine except that this must be run by an Exchange Administrator. Since we cannot be given Exchange admin rights, we must hand off a package including the script and pictures for an Exchange Administrator to execute.
The Set-UserPhoto cmdlet reliably updates the profile image in Exchange which includes Delve, the People app, profile pictures shown in the Outlook app, and likely other areas such as Skype for Business.
If that was all we had to do, this would be easy. However, many times Set-UserPhoto does not update the profile image as seen in SharePoint from a people search, a people picker field configured to show the image, or any custom web part that shows a profile image.
Uploads to User Photos Library
Waiting 72 hours after Set-UserPhoto seems to help for some accounts. It is the documented rate at which the profile pictures are synchronized from Exchange Online to SharePoint Online. So maybe we can just be patient and stop at step #3! I wish…
I have observed in multiple tenants that some profile pictures just don’t make it over to SharePoint Online. I can see that they don’t work by waiting 72 hours and then going to SharePoint search (e.g., https://<tenant>.sharepoint.com/search) and entering the username or email, then clicking on People to get people results.
I can also create a custom list of people picker fields configured to show a 36×36 or 48×48 profile image.
I haven’t figured out why Set-UserPhoto works for some accounts and not others, but since I know the profile pictures are supposed to get synchronized to the User Photos library in the My Site Host site collection, I have decided to upload profile pictures directly to that library. The library has a Profile Pictures folder (assuming the My Site Host locale is English) where the pictures belong. The URL looks like: https://<tenant>-my.sharepoint.com/User%20Photos/Profile%20Pictures and this article describes the filename format and that you have 3 different sized pictures for each profile picture. UPDATE: Another good resource is demystifying User Profile picture sync in #Office365.
Manually (or programmatically) uploading profile pictures here helped fix
most of those that were not properly migrated by Set-UserPhoto. Unfortunately, it was “most” but not all. It seems that patience may once again be required before all of them finally work. I haven’t seen this documented and it isn’t clear if this a 72-hour window or what. If I ever figure out a pattern here, I’ll update this post or mention it in the comments. UPDATE: What I have found is that testing these requires using a “clean” browser. Make sure you use one with its cache cleared (Guest/InPrivate/Private/Incognito). These updates should be available immediately. In my case, I tested 14 accounts ranging from 10-30 minutes of when I made these updates.
Profile Picture Aspect Ratio
Microsoft 365 wants a square aspect ratio for profile pictures and in many cases, this is shown as a circle. If you give it a rectangular image, Set-UserPhoto will crop the image to make square. However, if you upload the image into the User Photos library it will not be cropped and instead will be squeezed (or squished, if you prefer). Therefore, if some of your profile pictures are not square, you’ll want to crop them if you are uploading to the User Photos library.
Good luck on your journey of migrating profile pictures to Microsoft 365. A little divine intervention might help! If this post helped or you have any feedback, please leave a comment!