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 = 'john.doe@contoso.com'

$userphoto = "C:\Temp\"+$user+".jpg"

Set-UserPhoto -Identity $user -PictureData ([System.IO.File]::ReadAllBytes($userphoto)) -Confirm:$false

(Documentation for Set-UserPhoto is here: http://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. http://technet.microsoft.com/en-us/library/jj688150.aspx

Comments (4)

  1. Philippe says:

    Hi
    If I don’t use the proxy, remove-userphoto work but the command set-userphoto reject my 26ko photos, too large …
    If I use the “/?proxyMethod=RPS” with the commands set-userphoto or remove-userphoto it doesn’t work :c/
    I have an error with html code saying … that it can’t give me information on the error !
    Someone has already had this problem ?

  2. Gen_ky says:

    Thanks a lot

  3. Todd says:

    Thanks for this post, I still have the problem, I’ve opened a ticket with microsoft

Skip to main content