Get-MgUserPhotoContent does not return what was set using Set-MgUserPhotoContent

Müller Martin 5 Reputation points
2023-10-30T12:50:08.5433333+00:00

Describe the bug

When using Set-MgUserPhotoContent and then Get-MgUserPhotoContent, the returned value is not the same as was set using Set-MgUserPhotoContent. I assume the image is compressed.

To Reproduce
Set-MgUserPhotoContent -infile C:\Temp\photoIn.jpg
Get-MgUserPhotoContent -outfile C:\Temp\photoOut.jpg

Expected behavior
I would expect the two files to be identical

Debug Output
not applicable

Module Version
2.8.0

Environment Data
Name Value


PSVersion 5.1.19041.3570
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3570
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Additional context
This is important for tools syncing photos. MIM for example. MIM performs a "confirming import" to check if the correct value was set in the target system.

Microsoft Exchange Online
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,057 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,306 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,219 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Miguel Gonçalves | AVANADE 546 Reputation points
    2024-06-12T14:54:42.1566667+00:00

    Hi Muller,

    When using the Set-MgUserPhotoContent and Get-MgUserPhotoContent cmdlets, it’s indeed expected that the two files may not be identical due to various factors, including image compression.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/set-mguserphotocontent?view=graph-powershell-1.0

    https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/get-mguserphotocontent?view=graph-powershell-1.0

    0 comments No comments