PowerShell Script Does Not Finish (Reports Deliver, Script Never Ends)
What you’ll see
- Your ReportWORQ job runs successfully
- Reports are delivered
- The PowerShell script never finishes (the process appears to hang)
How to fix it
Add one line to your PowerShell script.
Step-by-Step Instructions
Open the PowerShell script
Open the script you use to run the ReportWORQ job (for example: RunJob.ps1) in a text editor.
Add this line at the top of the script
Add the line below near the top of the file, before anything else runs:
$PSDefaultParameterValues['Invoke-WebRequest:UseBasicParsing'] = $true
Before and After Example
Before (script never ends)
# Run ReportWORQ job
Invoke-WebRequest -Uri $url -Method Post -Body $payload
After (script completes normally)
# Fix for Windows Server PowerShell behavior
$PSDefaultParameterValues['Invoke-WebRequest:UseBasicParsing'] = $true
# Run ReportWORQ job
Invoke-WebRequest -Uri $url -Method Post -Body $payload
Save and re-run
- Save the file
- Run the script again
- The job will still deliver reports and the script will now finish
That’s it
No other changes are required.
If the script still does not complete after this change, reply to this post and let us know.
This change will be implemented in our April release.