[UPDATE] As of 4/25/2024 (tested), the latest version of the Graph SDK (2.18.0) has resolved these issues. Per GitHub, the fixes were rolled out with 2.17.0, so that version and any further versions should work just fine. PREVIOUS WORKAROUND was to downgrade to 2.10.0.
------ ORIGINAL POST BELOW ------
I have connected successfully to Graph using PowerShell Graph SDK. I have tested this using two different connection methods (DelegatedUser with Token, and App Secret). I can perform various operations just fine using the Graph PowerShell SDK, but this one command to update a user's profile photo (Set-MgUserPhotoContent) always returns the same error (see bottom of post).
I have confirmed the following commands are working just fine:
- Create a folder in another user's mailbox using New-MgUserMailFolder
- Get another user's profile photo using Get-MgUserPhotoContent
Problems seen so far in Graph module v2.15.0):
- Error when running Set-MgUserPhotoContent (see below) - Registry error
- Error when running Remove-MgUserPhoto - Cmdlet unavailable
So it's not my connection to Graph, and I don't believe it's my permissions. Here is an output from Get-MGContext, showing the User.ReadWrite.All permission:
$UpdatePhotoResult = Set-MgUserPhotoContent -UserId $EmailAddress -InFile $InFilePath
The error below has occurred on my own Win11 workstation and on a Server 2016 server.
Set-MgUserPhotoContent : Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
At line:1 char:5