Page 1 of 1

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

Posted: Mon Feb 24, 2020 9:27 am
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!

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

Posted: Mon Feb 24, 2020 9:42 am
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.

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

Posted: Mon Feb 24, 2020 9:51 am
by jvierra
I just did a quick test. The ProgreessBar is visible in a CLI build but not in a WIndows Host build.

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

Posted: Mon Feb 24, 2020 10:02 am
by jvierra
I found that it only displays if you package with "Sapien PowerShell V5 Host (Windows)"

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

Posted: Mon Feb 24, 2020 11:02 am
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.