Open danchevv opened 12 months ago
Thanks for bringing this to our attention.
Could you please share the output of $error[0] | fl -Force
right after the error has occurred to help us understand the error as we are not able to repro on our end. Also, does error occur in PowerShell 7, the latest version of PowerShell?
@peombwa , we are not using Powershell 7 yet
Same here as @tkudya But on every upload try. Same in pwsh7.
Here are the log outputs for Powershell 5:
Exception : System.Net.Http.HttpRequestException: An error occurred while sending the
request. ---> System.Net.WebException: The request was aborted: The
request was canceled. ---> System.IO.IOException: Cannot close stream
until all bytes are written.
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean
aborting)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean
aborting)
at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState
closeState)
at System.Net.ConnectStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.Http.HttpClientHandler.<>c__DisplayClass109_0.<GetRequestS
treamCallback>b__0(Task task)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RedirectHandler.<Se
ndAsync>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.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.RetryHandler.<SendA
sync>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.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Kiota.Http.HttpClientLibrary.Middleware.CompressionHandler.
<SendAsync>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.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Graph.PowerShell.Authentication.Handlers.AuthenticationHand
ler.<SendAsync>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.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Graph.PowerShell.Users.<UserSetPhotoContent_Call>d__441.Mov
eNext()
--- 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.Mov
eNext()
--- End of stack trace from previous location where exception was thrown
---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
at
Microsoft.Graph.PowerShell.Users.<UserSetPhotoContent>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.HandleNonSuccessAndDebugg
erNotification(Task task)
at Microsoft.Graph.PowerShell.Cmdlets.SetMgUserPhotoContent_Set.<Process
RecordAsync>d__57.MoveNext()
TargetObject :
CategoryInfo : NotSpecified: (:) [Set-MgUserPhotoContent_Set], HttpRequestException
FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.SetMgUserPhotoContent_Set
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Set-MgUserPhotoContent<Process>, C:\Program Files\WindowsPowerShell\Modu
les\Microsoft.Graph.Users\2.6.1\exports\ProxyCmdletDefinitions.ps1: line
47761
at <REDACTED due to PII>,
<REDACTED due to PII>.ps1: line 204
at <ScriptBlock>,
<REDACTED due to PII>.ps1: line 314
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
I'll post an update once I test with Powershell 7.
I am having the same issue. On PowerShell 7 with Microsoft.Graph.Users module version 2.2. Below is the error
`writeErrorStream : True
Exception : System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: The request was canceled. ---> System.IO.IOException: Cannot
close stream until all bytes are written.
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
at System.Net.ConnectStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.Http.HttpClientHandler.<>cDisplayClass109_0.
As of now, I have not been able to reproduce the issue with Powershell 7. I installed it via the x64 MSI file and did not add it to the path nor ticked any other checkbox during the installation. Seems to be working for now.
As of now, I have not been able to reproduce the issue with Powershell 7. I installed it via the x64 MSI file and did not add it to the path nor ticked any other checkbox during the installation. Seems to be working for now.
Thanks for confirming and providing the stack trace. We will use this issue to investigate why the error is occurring in PowerShell 5.1.
@tschwa21, you may want to first update your SDK to version 2.8.0. Several improvements and bug fixes have been made to the SDK since v2.2.0. See release notes at https://github.com/microsoftgraph/msgraph-sdk-powershell/releases for more details.
Same issue here on 2.8.0 version. On my Windows 10 system it works fine, but on Server 2016 it fails almost for every user with error "An error occurred while sending the request."
What seems to solve the issue on the Server OS is to resize the images to the height of 188 pixels and add some wait time between Set-MgUserPhotoContent calls.
In my case there is no chance to get a photo uploaded. Regardless of the operating system. What is the correct way to handle this? The retirement of the old powershell commands is soon and error handling or error information of the new Graph APIs is horrible. We can't just sit around try to change sizes and hope that the request will go through. Please provide accurate error messages, we can work with.
As of now, I have not been able to reproduce the issue with Powershell 7. I installed it via the x64 MSI file and did not add it to the path nor ticked any other checkbox during the installation. Seems to be working for now.
Thanks for confirming and providing the stack trace. We will use this issue to investigate why the error is occurring in PowerShell 5.1.
@tschwa21, you may want to first update your SDK to version 2.8.0. Several improvements and bug fixes have been made to the SDK since v2.2.0. See release notes at https://github.com/microsoftgraph/msgraph-sdk-powershell/releases for more details.
Still having the issue on 2.8.0.
I am also having this issue on PS5.1 with SDK 2.8.0. Every single photo I try to upload causes the error.
Also having this issue with PS5.1. Tried upgrading to 2.9.1 and still seeing it.
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method: PUT
Absolute Uri:
https://graph.microsoft.com/v1.0/users/
Headers: FeatureFlag : 00000043 Cache-Control : no-store, no-cache User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22621; de-AT),PowerShell/7.3.9 Accept-Encoding : gzip SdkVersion : graph-powershell/2.8.0 client-request-id : 9f4ce00b-bae3-4b51-9791-abd5e7d445b8
In PowerShell 7 with graph 2.8.0 it worked now.
I am still having issues on Powershell 5.1 with graph 2.11.1
Similar issue with Set-MgDriveItemContent which I believe uses the same dependencies. Most common if trying to upload files sequentially. Workaround seems to be add delay between uploads.
This is still happening with module version 2.19.0 in PS5.1 Desktop.
Same error using Azure Automation account runbook with powershell 5.1. All MgGraph updated to latest.
Hello, is there no solution to this issue? Still not working with 2.20.0... I was forced to use this command since Set-UserPhoto was deprecated but Set-MgUserPhotoContent does not work...
I can't find any solution on the Internet.
Getting the same errors: Set-MgUserPhotoContent : An error occurred while sending the request. CategoryInfo : NotSpecified: (:) [Set-MgUserPhotoContent_Set], HttpRequestException
Thanks!
@PSBoon825 - I have converted my script to use powershell graph api instead, its more reliable than this command
@PSBoon825 I will repeat myself, but what "solved" this issue for me was to resize the images to the height of 188 pixels and add some wait time between Set-MgUserPhotoContent calls.
@tkudya Thanks for the hint, this looks much more complicated though since I'm not experienced with API calls. Do you happen to have some example code?
@ztrhgf Thanks for your reply. This happens to me even when running the command only once sometimes. Sometimes it works, sometimes it doesn't. Very unreliable. I read somewhere that the images should be converted to 648x648 for the MS cloud uploads, so isn't 188 against the "best practice"?
Describe the bug
To Reproduce Steps to reproduce the behavior:
Expected behavior Either a clear error on what the problem was or the picture to be changed successfully.
Debug Output 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.d5.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.d1.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.d441.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Graph.PowerShell.Users.d441.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 57.MoveNext()'
DEBUG: [CmdletException]: Received exception with message 'PipelineStoppedException - The pipeline has been stopped. : at System.Management.Automation.MshCommandRuntime._WriteErrorSkipAllowCheck(ErrorRecord errorRecord, Nullable`1 actionPreference)
at System.Management.Automation.MshCommandRuntime.DoWriteError(Object obj)
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at System.Management.Automation.MshCommandRuntime.WriteError(ErrorRecord errorRecord, Boolean overrideInquire)
at System.Management.Automation.Cmdlet.WriteError(ErrorRecord errorRecord)
at Microsoft.Graph.PowerShell.Cmdlets.SetMgUserPhotoContent_Set.d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Graph.PowerShell.Cmdlets.SetMgUserPhotoContent_Set.d__57.MoveNext()'
Module Version Get-Module Microsoft.Graph*
ModuleType Version Name ExportedCommands
Script 2.6.1 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Environment Data $PSVersionTable
Name Value
PSVersion 5.1.20348.1850 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.20348.1850 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Screenshots N/A
Additional context We are authenticating with a client secret to an application which has the necessary permissions to change the pictures. Again, this seems to work for most users, but in some odd cases it fails for some for no valid reason. Usually it tends to succeed for 80-90% of the users, and on rare occasions it won't fail at all. Is there some throttling mechanism at hand here?