Hi Maksymilian!
That is a good suggestion, tried that.
Unfortunately it didn't work.
Maybe Start-Job is not the right choice, because it starts a new thread.
If I run the attached script directly on server, it works like a charm.
Could you please post a snippet on how you are starting powershell script?
Thank you & have a nice day!
I'd just skip that Start-Job, in my example I'm just generating an XML file, but as a direct script, without any additional functions.
New thread shouldn't be necessary, just add -TimeoutSec parameter, to make PowerShell wait for the request to complete.
Invoke-WebRequest https://www.example.com/longrunningtask -ConnectionTimeoutSeconds 60 -OperationTimeoutSeconds 60 (would try both)