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.
Locked
User avatar
timstspry17
Posts: 45
Joined: Sun Sep 06, 2015 9:31 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: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

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: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

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
Joined: Sun Sep 06, 2015 9:31 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.

Locked