Description
Describe the bug
Set-MgUserPhotoContent is returning to the host before it has completed the Graph API to upload the photo file.
I'm using Set-MgUserPhotoContent in a script in a try block where the very next line is a Remove-Item cmdlet to delete a temporary image file. The Remove-Item cmdlet is deleting the file before Set-MgUserPhotoContent has completed the Graph API to upload it which then causes and error for Set-MgUserPhotoContent.
Also tried while using the -PassThru parameter and assigning the output to a variable.
Expected behavior
Set-MgUserPhotoContent should not return until the underlying Graph API call is complete or errored. Or have a parameter that enables it to wait.
How to reproduce
$user = [email protected]
$file = get-item .\tempphoto.jpg
Set-MgUserPhotoContent -UserId $user –InFile $file.FullName
Remove-Item $file.FullName -force
SDK Version
2.19.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
DEBUG: Content type
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
PUT
Absolute Uri:
https://graph.microsoft.com/v1.0/users/72f917be-3a85-4ee4-9a10-01eeded8c31c/photo/$value
Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.14393;
en-US),PowerShell/5.1.14393.6343
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.19.0
client-request-id : fd01ac23-ecae-42c5-8ce4-0164b71f32de
Body:
�����jExif II* � �� �
� ��� � �� ��� � � ��� � � ��� � � ��� � ��� � � ��� � � ��� � � �� � (�� �
� 1�� � �� 2�� � !� ��� � � i�� � 8� %�� � 0� D� NIKON CORPORATION NIKON D7500 ��
�' ��
�' Adobe Photoshop 25.9 (Windows) 2024:06:12
08:27:49 - ��� � Z� ��� � b� "�� � � '�� � d 0�� � � 2�� � d � � 0231��� � j� ��� � ~
� ��� �� ��� �� ��� �� �� � ��� ��� � �� ��
� �� ��� � �� ��
� �� ��� � �� �� � � �� � �� � �
�� � �� �� , �� ��� � 59 ��� � 59 ��� � 59 � � 0100��� � � ��� � �� ��� � �� ��� � ��
��� � � � � � �� � � �� �� ��� � ��� � � ��� � � ��� � H ��� � �� �
�� � �� �
�� � �� �
� ?
2024:06:04 08:10:18 2024:06:04 08:10:18 -04:00 -04:00 -04:00 � � ��F @b� Q @b� � -
h�
ASCII � � ��� � � � � R98 � � 0100 � � � �� � ��� �
� ��� � �� �� � � (�� � � ��� � �� ��� � �� H � H � ���� Adobe_CM ��� �Adobe d� ���
��
���������������������
� ���" �������� �
���? �������� � ����
�� �������� � ����
�� ����������3� ����!�1�AQa�"q�2�����B#$�R�b34r��C%�S���cs5����&D�TdE£t6��U�e���u��F'��������������Vfv��������7GWg
w��������� ������������5� ���!1��AQaq"��2�����B#�R��3$b�r��CS�cs4�%�����&5��D�T��dEU6te����u��F��������������Vfv����
����'7GWgw������� �� ���� ? �k�
�b��G�J�2r�r^mɺ��:o��{��{��_i,|��?���ϱ��֏�s�RP��*�9;x�s���}]�/�8QK,e��,qv��{�� A$>��E�G�!���ZA�5�d~>�"����� G� a��v���%"В���� ����� �9��v�<�[� ��V�c�@q��>��I ����2�?"(btL��Ħ!������M�2y����☔ܤ��)�T���-�)Md����|W������W������8�{��Z?�O�ǫ�S�� �.��T���;��-�&)m�е��p��N
3�z���kckffC�������?K��.������� W�}��� Z���k��;�W��)���CNRk��5��=����
��2JQ�Q%K�
��b�oT���"b;J�pf�����|>�T\���$��D1c���������w �_ӏ/�$�r<��'2�ui�D���n���� ��c� "���������et�ݸ����
�c�
읭��j�
!p�m��S���c5.D�V/�L�Ӿ�]c�[e��������Ԕ�� Y����S�q��}��ݴ���������-���4���\O��j?N,p�]V#u��h���F�F�@�E���8�#�:�1�1^ͮ� �� h"V�X�����H��pF ����&8p���»ѽ��Iw�z�^;\����^��q��ͬ.��k���Vpe2�&�1�F�_R�;�j~ݻ����G ��#D�O���N���u'���X�W$���W�����;������
'��?���SkI)���@��H�J]��4��������ؒ����{.q� �]@��� ����1\�75��W5��c�x�LI����M�
�c��s���0����N�o��Lz��-e@n���
��_'?�R��-�����Q"�m.��5��\��Y$Oܣ�@�G�,dOP|�w�!��
]W�Y.���n-s��V���s?�vĢ��O��H�H�n�3��̀9�����v��������@�Y#�kL|���˨�VU;�{mc��������X�|�S]�>�jG�$#BZuVAp�^����� ����w�z��D�
�c@�R�p��>��>��� ����b��r����v��hN֩ �R����S������
����ݭRO��j(Z��H�ȍ��PVc
+�� ���o���=�����1��ȧ�C��1���ձ���?�U��Ҳ�����Ǚ���[�o��'�H�+�����t��M��A�o��������V��1���8w��#?1��X��1��"�ܻ�gn����>b��
��s��8λ�ƪ�����9���kev}�ѻ���d7���_N��$�t��q�9�ջ{�N��W8���^�s����R��c�2}k���o��$��� ̓,��h� �]���ns��-ic��������Vs+�~5Y�
U���9�c���Ӎ���ҿ�.h��9���1"=������V��{��.��}2u�����$l� F��O��׆�.k}'\K���iy���������v��;h$���52N�˭����):�,�q��qqA���?v
�ӿ���� V����k�S^?G��a��4��'K
�a$� ����J��4W�I�'�sr�Fr�6�X%<"WWtV�"�i��F1Ol��� ��뚤���J3Z�B�hF����B+��/����잃]�������LJP_���R��E��m
o��6ʬie��5�p��=��5�M"�.��d�g�q\�\O&u]oN��X?������������������s����a�k�w�*s�;�
���\�1<|�l�#F� ��ػ]C.���+��x<��������EVL��;��ǩ�z/Z�;��������>{��{�0�r����i
��5{L���^�o�Ozdbj�s$��u������6�K��O�������c��Z�X����_Q�KK"ڱ�-��:�� m����������釫Y��e�}����}���Ս�7��Hƺ��kb<õ��I>=�f8��j� 5[-^�M��k21�}�����qc��[���E歱��Z�6[�G��<��� ���㨐|��c'���-_l�}_���M�7!�
��nk����:���vߣ���bװ��L�}#��n+rniq��ư��X?GN�~w����!�2@Y�$q�M�ѻ��}��� ���>㹿�Q���h���(��S�#�##�D���k$�,d�����B� 6X� r����(.?z �����\p��8 [>�E�s2�Z��j��Q������<.Ȩ�[e �[����� ����y�����n�>!z�^��:�P����kY I%�s���r���ָv���P �d�է 2ӧc�,>�I ������ �K�m۠���,sZ����A�o����6F�$��g��+2���N�� 7�)����6���P�oO��K��X?2�� 8���e_��mlcZ�7k��X���mc��\���Q_P�<��Üy%�3_���-Vp #c�K ��3��?��'kT���������� �79%#y���'(L$������0<��e��I���2������)vĪ�k��t>�oQ�~ګѕ��m���z��� ���~�7T��������=<z����?B�����?w��g�}d������}�,�u�,� �i�SY?D�����S����'ҭ�ĕ[��W�=W��|����u��X��� �iw�ʱ���L�w�����O�~����q�.ø��a� �O����� ��ع���W�OP�!��w{2X�K���s�ݽz�8��X-¹���,����t~��~�\��n�3��FL��e�ߥ�_;��C� �{��z� [�f�����X?�W��@\�Ռ����D>��uo�{7��F� �w����D<T�y�y���P��cP![��2|��X h����cW!���b�F�N��&�-~s�����Z�>�� �W~�� �Q ��ױ������'>��q� �K\� ��O��� "��u��[wSб�R4�fP-g�����g��������3//; ,�M?G��j��$�1���RpO���y/@� �]I�X�t[��lo�b�ɨ��V��/k�� ��� ������ԯ�]G� �Q��������7R��s�H���u}���ͤQ�!��f�5������30r0n5Z��%����;�+��}��T�R�R���j���=F;��%�S2h�-��a�LG��=�� ��e�'��M�9�4:��l��< � ��� >����?�,;��~�
�ٖ�ƭ����=�ߥl����R���5-�䄇�"��R���p���1Cd�Yf�K���_HꙘ�����2o�����[-��������ƍ���C�
g����?�
˲�_�+&��~�_�+��m-����F3v���f?�o�����Fڱ
�Z�SafauV���̜w�;���w�Wcg�]��RsTk������$?���z�W�U���U�pe�X譧����q����v���!8��Ց��$�C��65��/0��s��nݼ��)<�1Ţ\���3
���{�� ���LT�b��S� ��X��G�Ǻo鏆�ދf�5� ��ף��ֻ1�����1�^)�/�~��ō�c��~͔LG�in�
?�o��� ��p#Y�5��6H����c��V8�-���ѭ����6?O���M,mt�H`�'��{���� H�<�z�G�3鰗��4���x����u�_R��������������-����c��+���� ��Ƚ�륆
���������������<
l]Vd7L��y���
�r�X������������[Ύuq���uO���� Ʊ��?�:��W��e|}����i͘�qe���� �\0N�(��H%��,�.��������d��5�I�c����Ϯ�z)���u��Ϭ�{�����sO��{G�J�2r�r^mɺ��:o��{��{��_i,|��?���ϱ��֏�s�RP��*
1�om���W� ůU-�����xJ�m�����NPhotoshop
3.0 8BIM�� ,��Z ��� � ��720240604��< �081018-04008BIM�% ���O��?�5y���7n8BIM�: �� � � �print
Output � PstSbool� Inteenum Inte Clrm �printSixteenBitbool �printerNameTEXT � O K I
C 9 3 1 ( P C L 6 ) �printProofSetupObjc P r o o f S e t u p
proofSetup � Bltnenum builtinProof
proofCMYK 8BIM�; �- � � �printOutputOptions � Cptnbool Clbrbool RgsMbool CrnCbool CntCb
ool Lblsbool Ngtvbool EmlDbool Intrbool BckgObjc � RGBC � Rd doub@o� Grn
doub@o� Bl doub@o� BrdTUntF#Rlt Bld UntF#Rlt RsltUntF#Pxl@R
vectorDatabool� PgPsenum PgPs PgPC LeftUntF#Rlt Top UntF#Rlt Scl
cropRectRightlong WhenPrintingbool �cropRectBottomlong cropRectLeftlong
�cropRectToplong 8BIM�� � H � � H � �8BIM�& � ?� 8BIM��
� x8BIM�� � �8BIM�� � 8BIM'�
� �8BIM�� H /ff � lff � � /ff � ��� � � 2 � Z � � 5 � - � �8BIM�� p �����������
������������� ������������������������ ������������������������ ������������������������ 8BIM � � �@
�@ 8BIM�D � � �@ �@ 8BIM�� � 8BIM�� �] � �� �� � T o n g _ G a r y _ 6 - 2 4 _
4 4 6 3 0 � � �� �� � � � null � �boundsObjc
� Rct1 � Top
long Leftlong Btomlong �� Rghtlong �� �slicesVlLs �Objc � �slice � sliceIDlong
autoGenerated Typeenum m ESliceOrigin
ESliceType Img �boundsObjc � Rct1 � Top
long Leftlong Btomlong �� Rghtlong �� �urlTEXT � nullTEXT � MsgeTEXT � �altTag
TEXT � �cellTextIsHTMLbool� cellTextTEXT � horzAlignenum �ESliceHorzAlign default
vertAlignenum �ESliceVertAlign default �bgColorTypeenum �ESliceBGColorType None topOutsetlong
leftOutsetlo�����jExif II* � �� �
� ��� � �� ��� � � ��� � � ��� � � ��� � ��� � � ��� � � ��� � � �� � (�� �
� 1�� � �� 2�� � !� ��� � � i�� � 8� %�� � 0� D� NIKON CORPORATION NIKON D7500 ��
�' ��
�' Adobe Photoshop 25.9 (Windows) 2024:06:12
08:27:49 - ��� � Z� ��� � b� "�� � � '�� � d 0�� � � 2�� � d � � 0231��� � j� ��� � ~
� ��� �� ��� �� ��� �� �� � ��� ��� � �� ��
� �� ��� � �� ��
� �� ��� � �� �� � � �� � �� � �
�� � �� �� , �� ��� � 59 ��� � 59 ��� � 59 � � 0100��� � � ��� � �� ��� � �� ��� � ��
��� � � � � � �� � � �� �� ��� � ��� � � ��� � � ��� � H ��� � �� �
�� � �� �
�� � �� �
� ?
2024:06:04 08:10:18 2024:06:04 08:10:18 -04:00 -04:00 -04:00 � � ��F @b� Q @b� � -
h�
ASCII � � ��� � � � � R98 � � 0100 � � � �� � ��� �
� ��� � �� �� � � (�� � � ��� � �� ��� � �� H � H � ���� Adobe_CM ��� �Adobe d� ���
��
���������������������
� ���" �������� �
���? �������� � ����
�� �������� � ����
�� ����������3� ����!�1�AQa�"q�2�����B#$�R�b34r��C%�S���cs5����&D�TdE£t6��U�e���u��F'��������������Vfv��������7GWg
w��������� ������������5� ���!1��AQaq"��2�����B#�R��3$b�r��CS�cs4�%�����&5��D�T��dEU6te����u��F��������������Vfv����
����'7GWgw������� �� ���� ? �k�
�b����v�<�[� ��V�c�@q��>��I ����2�?"(btL��Ħ!������M�2y����☔ܤ��)�T���-�)Md����|W������W������8�{��Z?�O�ǫ�S�� �.��T���;��-�&)m�е��p��N
3�z���kckffC�������?K��.������� W�}��� Z���k��;�W��)���CNRk��5��=����
��2JQ�Q%K�
��b�oT���"b;J�pf�����|>�T\���$��D1c���������w �_ӏ/�$�r<��'2�ui�D���n���� ��c� "���������et�ݸ����
�c��9;x�s���}]�/�8QK,e��,qv��{�� A$>��E�G�!���ZA�5�d>�"����� G� a��v���%"���� ����� �9
읭��j� !p�m��S���c5.D�V/�L�Ӿ�]c�[e��������Ԕ��
DATA TRUNCATED DUE TO SIZE
DEBUG: [CmdletException]: Received exception with message 'HttpRequestException - An error occurred while sending the
request. : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RedirectHandler.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.PowerShell.Authentication.Handlers.AuthenticationHandler.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.PowerShell.Users.<UserSetPhotoContent_Call>d__441.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Graph.PowerShell.Users.<UserSetPhotoContent_Call>d__441.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.PowerShell.Users.d__439.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.PowerShell.Cmdlets.SetMgUserPhotoContent_Set.d__69.MoveNext()'
Configuration
-OS: Windows Server 2016 x64
Name Value
PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Other information
No response