Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 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.
Locked
User avatar
timstspry17
Posts: 45
Last visit: Tue Apr 18, 2023 2:49 pm

Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Post by timstspry17 »

Hello, I have a problem where the progress bar will display from the Backup-SqlDatabase command which I execute via the Invoke-Command cmdlet. The problem is the progress bar displays just fine when I am running my PowerShell project from within PowerShell Studio 2020. However it does not display at all when I run the .exe generated by building the PowerShell project.

Any help would be appreciated!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Post by jvierra »

The progress bar requires a UI. It's display would depend on the type of EXE you are building.

In forms script the ProgressBar should display normally as a GUI ProgressBar.

When running in an Invoke-Command the progress bar will not display because the command is run remotely.

The backup command does not require remoting. It is a SQLServer command that is designed to run locally and do its own connection to any server instance in the network. When run this way the ProgressBar should display normally.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Post by jvierra »

I just did a quick test. The ProgreessBar is visible in a CLI build but not in a WIndows Host build.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Post by jvierra »

I found that it only displays if you package with "Sapien PowerShell V5 Host (Windows)"
User avatar
timstspry17
Posts: 45
Last visit: Tue Apr 18, 2023 2:49 pm

Re: Displaying progress bar from Backup-SqlDatabase function via Invoke-Command

Post by timstspry17 »

Thank you jvierra. That did the trick, although I'm not quite sure why packaging with "Saping PowerShell V5 Host )Windows Form did not function the same way, especially since I am using a form as the main point of my app.
This topic is 4 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.
Locked