Office 365 customers can utilize a script to set the thumbnailPhoto attribute in on-premise Active Directory to have user photos synchronized to Office 365 via Directory Synchronization (DirSync).

The photo import script supplied to customers can be found here:

Exchange Online has a strict 10KB size limit on thumbnailPhoto (, so we need to ensure that users’ photos stored in Active Directory are present, and are less than or equal to 10KB in size.

Office 365 Directory Synchronization will synchronize photos up to 100KB in size, and Exchange Online is currently the only Office 365 workload that imposes the 10KB photo size limit.

The following sample script reports counts of users whose Active Directory photos are either too big, are of acceptable size, or are not set. The script writes the userPrincipalNames (UPN) and photo size in KB to separate .log files, named appropriately.

As a side note, Exchange Online PowerShell offers a property on mailbox objects named HasPicture, which has possible values of True and False.

Example usage:
Get-Mailbox | where-object {$_.haspicture -eq $false} | select-object name | fl 

The results from the Get-Mailbox command can be misleading since the following scenario holds true:

  1. A user has a 7KB photo set in Active Directory and has been synchronized to Office 365 (the photo is displayed in the Exchange Online GAL, and HasPicture = TRUE)
  2. Later, the same user has a 40KB photo set in Active Directory and has been synchronized to Office 365 (this photo is too big for Exchange Online, but HasPicture remains = TRUE)


The following script sample allows customers to get photo size reporting directly from Active Directory so that they can see which photo is active now, and whether or not it is too large to be displayed in Exchange Online.


Note: Ensure you change the file extension from .txt back to .ps1 and also change the $Root variable in the script to match your root domain context.