Posts

Showing posts from February, 2021

The Set-AzureADUserThumbnailPhoto PowerShell cmdlet ImageByteArray"

When you try and set an Azure Active Directory user thumbnail using the ImageByteArray parameter the command fails and you see the following error System.Management.Automation.CmdletInvocationException:   ---> System.ArgumentException:      at Microsoft.Open.Azure.AD.CommonLibrary.Utilities.ImageUtils.GetImage(Stream fileStream, String filePath, Byte[] imageByteArray) in X:\bt\1205398\repo\src\dev\PowerShell.V2\CommonLibrary\Utilities\ImageUtils.cs:line 114 This appears to be a bug in the internal code of the PowerShell cmdlets. To work around this in C# you need to convert your byte[] array to a memory stream, and use the FileStream parameter. This should work as expected. /// <summary> /// Sets the thumbnail photo for the specified acccount. /// </summary> /// <param name=" identifier "> The user principal name or object identifier of the user for which the thumbnail photo value should be set. </param> /// <param name=" thumbnailPhoto