User Photo in Office 365 it’s a problem which was driving me crazy for last few weeks, event I wrote a lot of posts on official Microsoft forum. This one is based on personal experience of last few weeks when I was doing our local Active Directory integration with Office 365 and Azure AD. I am SharePoint guy and I just wanted to present my users photos in SharePoint. Unfortunately for some reasons user photos which were existing in my local active directory on premise installation didn’t appear in SharePoint online. Our local support says that everything is perfect. Unfortunately there was a problem.
I've detected an ad blocker...
This site relies on ad revenue to generate content.
Please consider disabling your ad blocker for my site. Thank you!
This my account in our on premise AD
But when I displayed my user in Office 365 there was no my photo
So what’s the problem with User Photo in Office 365?
Well, in case of user photo synchronization between on premise Active Directory and Office 365 we have consider a few things:
- user photos from local AD will not appear in all application of Office 365 in the same time!
- first place where user photo appears is Exchange online
- To present user photo from local AD photo size must be less than 10KB
- If there’s no user photo in Exchange online it will not appear in SharePoint online too…
- If we have photo in Exchane online we have to start sync process to SharePoint online
How to force sync process to SharePoint online
Everything seems to be simple but some time it doesn’t work as it should. Even as tenant administrator we can’t start synchronization in Office 365 interface of user photo to SharePoint online.
To start synchronization process each user should go to my sites or Delve. Also user can do following steps:
About me > press photo > Change photos > we are changing photos in Edit Details >
Usually it works. If we have a problem we can try following steps to get User Photo in Office 365:
- Go to SharePoint Online Admin Center in Office 365 admin portal> User profiles
- In People we select ‘Manage User Profiles’
- We are looking for the user who has a problem
- Let’s edit user profile and search for Picture Exchange Sync State
- Picture Exchange Sync State – change to 0, delete photo and save
- Picture Exchange Sync State – change to 1, save and check the result
It’s worth to remember which has very important impact on our solution. According to Technet thumbnailPhoto property is synchronized between Azure AD and Exchange Online only one time! All later changes in our on premise AD will not be send to Exchange Online.
Well, we still can use PowerShell
Connect to Exchange online:
$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session
We can change user photo with following command (base on Technet):
Set-UserPhoto "Paul Cannon" -PictureData ([System.IO.File]::ReadAllBytes("C:\Users\Administrator\Desktop\PaulCannon.jpg"))
Unfortunately this option described on Technet site in not accurate. If you get an error just like below you have to update your script
Error on proxy command ‘Set-UserPhoto -PictureData: …
‘False’ to server DB5PR07MB1368.eurprd07.prod.outlook.com: Server version 15.01.0390.0000, Proxy method PSWS:
Request return error with following error message:
The remote server returned an error: (413) Request Entity Too Large…
+ CategoryInfo : NotSpecified: (:) [Set-UserPhoto], CmdletProxyException
+ FullyQualifiedErrorId : Microsoft.Exchange.Configuration.CmdletProxyException,Microsoft.Exchange.Management.RecipientTasks.SetUserPhoto
+ PSComputerName : outlook.office365.com
In our script we have to update parameter -ConnectionUri. As you can see I added option ?proxyMethod=RPS . Also before we can use our photo we should encode it into variable.
$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxyMethod=RPS -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session -AllowClobber -WarningAction SilentlyContinue -ErrorAction SilentlyContinue $user1 = ([Byte] $(Get-Content -Path C:\1\Tomek1.jpg -Encoding Byte -ReadCount 0)) set-userphoto -identity email@example.com -picturedata $user1 Remove-PSSession $Session
And that’s all. I hope that this short post will help you to solve problems with user Photo in Office 365 during local Active Directory and Office 365