Progress bar when running PS cmdlet

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 2 years and 7 months 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
harringg
Posts: 18
Last visit: Mon Oct 30, 2023 11:13 am

Progress bar when running PS cmdlet

Post by harringg »

New to WinForms and progress bars.

I've got a button that installs RSAT tools (when the WinForm is run as Admin).

When running the command in the ISE (VSCode) it displays a progress bar in VSCode. Is it possible to have that shown in the WinForm? I've added progressbaroverlay1 to the Form at the bottom, but not sure how to "call" it (if even possible). I can add a loop function to check if it's installed and when it is, report via a pop-up, but a progress bar would be cleaner.

Code: Select all

$buttonInstallRSAT_Click={
	#TODO: Place custom script here
	Get-WindowsCapability -Name "RSAT*" -Online | where-object { $_.name -like "Rsat.NetworkController.Tools~~~~0.0.1.0" } | Add-WindowsCapability -Online
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Progress bar when running PS cmdlet

Post by jvierra »

Again you have too little useful information to know what your issue is.

See the online examples for how to use a ProgressBar.
User avatar
apowershelluser
Posts: 190
Last visit: Mon Mar 18, 2024 7:13 pm
Answers: 1

Re: Progress bar when running PS cmdlet

Post by apowershelluser »

Did you ever figure this out? I'm also curious as I'm facing a similar issue.
User avatar
Lembasts
Posts: 405
Last visit: Thu Mar 14, 2024 10:47 pm
Has voted: 1 time
Been upvoted: 1 time

Re: Progress bar when running PS cmdlet

Post by Lembasts »

User avatar
harringg
Posts: 18
Last visit: Mon Oct 30, 2023 11:13 am

Re: Progress bar when running PS cmdlet

Post by harringg »

I've got a progress bar working for "progress scripts". I was looking to output the progress bar when running "import-module activedirectory", like it does in the ISE.

And same with my OP question, that action, in the ISE has a "progress bar", just hoping to capture in the form.

In WINFORMS when first launching the form, it pops-out in a separate window (natively, nothing I've added to my scripts). Just hoping I could bring that "into" the actual form itself. May not be possible.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Progress bar when running PS cmdlet

Post by jvierra »

You can't with the AD module because it will be preloaded by the time the form executes. Import-Ad only takes a sedcond or less. If you import it on the froms "Shown" even then you may get a ProgressBar on slower computers but you won't get it on the "Load" even or earlier.
This topic is 2 years and 7 months 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