Uploading High Resolution Photos using PowerShell for Office 365
When first trying to upload a high-res photo for user’s mailboxes, you’ll likely start with the manual for Set-UserPhoto and try to write some Powershell script like the below command:
$user = 'email@example.com'
$userphoto = "C:\Temp\"+$user+".jpg"
Set-UserPhoto -Identity $user -PictureData ([System.IO.File]::ReadAllBytes($userphoto)) -Confirm:$false
(Documentation for Set-UserPhoto is here: https://technet.microsoft.com/en-us/library/jj218694.aspx)
When trying to run this, however, one might run into is an error when trying to upload a >10 kb photo, saying “The remote server returned an error: (413) Request Entity Too Large”. There is a fix for this! In the script that you use to create an Exchange Online Powershell session, make sure that the yellow highlighted section below is added. The normal proxy method won’t work for >10kb files.
$ExSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxymethod=rps -Credential $MSOLCred -Authentication Basic -AllowRedirection
Run the first script again, and it now works great with larger photos!
Do keep in mind that the photos you upload should be 648 pixels by 648 pixels if you want the maximum photo size for Office 365. That size comes from the Lync documentation, which explains how Exchange creates the multiple sizes that get used throughout the system. https://technet.microsoft.com/en-us/library/jj688150.aspx