Office 365 Powershell issue with Set-UserPhoto for anyone other than myself

10,239

just ran into the exact same problem.

the solution was to run Microsoft Azure Active Directory Module for Windows PowerShell 'as administrator' (Elevated)

as seen here https://www.blackforce.co.uk/2016/09/23/set-userphoto-error-proxy-command

Share:
10,239
Cole
Author by

Cole

Desktop Support Analyst

Updated on June 21, 2022

Comments

  • Cole
    Cole almost 2 years

    I'm a global admin for our 365 environment and I'm having an issue with the Set-UserPhoto command in powershell. If I run it for my own username, it works just fine but if I run it using anyone else's username, it errors. Is there some kind of access I need to give myself to make this work? I'm a domain admin and global administrator in 365 so I should be able to do anything.

    Connected through PowerShell 3.0 using the following:

    $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
    

    Command I'm running:

    Set-UserPhoto –Identity username -PictureData ([System.IO.File]::ReadAllBytes("C:\userpics\username.jpg"))
    

    Works fine for my username, for any other username I get this:

    Error on proxy command 'Set-UserPhoto -Identity:'username' -PictureData: Tons of numbers here that scrolls for quite a while -Confirm:$False' to server BN3PR0201MB1027.namprd02.prod.outlook.com: Server version 15.01.0534.0000, Proxy method RPS: The WinRM client cannot process the request. The connection string should be of the form [://][:][/] where transport is one of "http" or "https". Transport, port and suffix are optional. The host may be a hostname or an IP address. For IPv6 addresses, enclose the address in brackets - e.g. "http://[1::2]:80/wsman". Change the connection string and try the request again. . + CategoryInfo : NotSpecified: (:) [Set-UserPhoto], CmdletProxyException + FullyQualifiedErrorId : Microsoft.Exchange.Configuration.CmdletProxyException,Microsoft.Exchange.Management.Reci pientTasks.SetUserPhoto + PSComputerName : outlook.office365.com

    • Persistent13
      Persistent13 almost 8 years
      Is this the only command for Office 365 that you get the error for?
    • Cole
      Cole almost 8 years
      Haven't gotten any other error at all from any other command that I've had to do.
    • Persistent13
      Persistent13 almost 8 years
      Long shot but, how many groups is the account you used apart of? This would include AD in you have on-prem sync enabled. support.microsoft.com/en-us/kb/3067263 may be the cause and I figure O365 support would have to assist you further if it is.
    • Cole
      Cole almost 8 years
      @Persistent13 That's probably it I bet, my domain admin account is a member of a ridiculous number of groups. I'll do some testing and post back to confirm if that was it or not. Thanks!
    • Cole
      Cole almost 8 years
      Made a new user which is only a member of Domain Users, gave this user global admin in 365 and tried the command again and got the same result. Seems the number of groups was not the cause.
  • Preston Cooper
    Preston Cooper over 7 years
    All pictures must by 96 X 96 and less than 10KB
  • Preston Cooper
    Preston Cooper about 7 years
    I wrote an article about importing staff photos into Office 365. questiondriven.com/2017/01/20/…