Page 1 of 1

Progress bar when running PS cmdlet

Posted: Thu Jul 15, 2021 5:58 pm
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
}

Re: Progress bar when running PS cmdlet

Posted: Thu Jul 15, 2021 6:35 pm
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.

Re: Progress bar when running PS cmdlet

Posted: Tue Jul 27, 2021 5:57 am
by JohnTitor
Did you ever figure this out? I'm also curious as I'm facing a similar issue.

Re: Progress bar when running PS cmdlet

Posted: Wed Jul 28, 2021 10:05 pm
by Lembasts

Re: Progress bar when running PS cmdlet

Posted: Fri Jul 30, 2021 8:36 pm
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.

Re: Progress bar when running PS cmdlet

Posted: Fri Jul 30, 2021 9:05 pm
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.