How can Invoke-WebRequest change ProgressBar?

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
KlausGB
Posts: 4
Last visit: Thu Feb 28, 2019 7:07 am

How can Invoke-WebRequest change ProgressBar?

Post by KlausGB »

Hi

i am a beginner with PowerShell and a total beginner with PowerShell Studio ;-)

Product, version and build:
Powershell Studio 2019 5.6.159.0 64 bit
Operating system:
Win 10 64 Bit 1803

i am writing a powershell-program to download the newest version of my programm. i have to download one big EXE (=installation program)
in my powershell-program i check internet connection, if my program is available, if it is neccessary to download, and so on.
Everything works so far, but i am not able to fill the progress bar while downloading .
i have a form with a download-button. if this is clicked, i use Invoke-WebRequest to download the file i want. the file is downloading, but the progressbar shows always "0%".
i try $ProgressPreference = "SilentlyContinue" or not, no difference.
if i comment out $ProgressPreference, the compiled version shows nothing, but if i run it in PowerShell Studio, there is an other progressbar shown (this is default i mentioned).

What should i do?
i have no more ideas to try.

Best Regards
Klaus
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: How can Invoke-WebRequest change ProgressBar?

Post by davidc »

The Invoke-WebRequest's progress bar option is host dependent. Therefore, depending on which packager engine you selected, you may not see the progress bar at all. Do you recall the engine you selected?


If you added a progress bar control to your GUI, you have to manually update the progress bar. Unfortunately, I don't believe there is no way of redirecting Write-Progress without having a custom host.

You could potentially use a "Button - Start Job" to invoke the web request. This control set, will disable the button and animate it, until the job is completed.
Button - Start Job Control Set.png
Button - Start Job Control Set.png (26.48 KiB) Viewed 18920 times
But is will not display the step by step progress unless the host supports it.

If you have GUI related questions, I recommend posting on the PowerShell GUIs forum:

https://sapien.com/forums/viewforum.php?f=21
David
SAPIEN Technologies, Inc.
KlausGB
Posts: 4
Last visit: Thu Feb 28, 2019 7:07 am

Re: How can Invoke-WebRequest change ProgressBar?

Post by KlausGB »

Thank you
i solved it using BITS
This topic is 5 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.