Jobs and DGV

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 5 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
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Jobs and DGV

Post by MarvelManiac »

Hello,

I found this script online that's been working great for me if not in a job (ISE and or just a normal button click event). Once I try to insert the code into a Button-Start Job control set, it returns no results.
JobPingTest.psf
(32.33 KiB) Downloaded 165 times
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Jobs and DGV

Post by mxtrinidad »

Rule of thumb here is.. If it works in the console then you can use the same block of code in the JobTracker function with little or no changes.

In your case, splitting the code is not working, also I won't recommend using the same Variable name with the parameters.
Also, the use of '-ArgumentList' parameter are meant to pass single string and not arrays values.

Attached is a modified form for ping only. You can make the necessary changes.
JobPingTest.psf
(29.52 KiB) Downloaded 130 times
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Jobs and DGV

Post by mxtrinidad »

My Apology and Good news!!

I figured out the changes needed for your script to work. Only two changes required:

1. In the "-UpdateScript' parameter, comment out the next line as is not really needed.

Code: Select all

		#$results = Receive-Job -Job $Job;
2. In the '-ArgumentList' parameter, need to have an open/close parenthesis:

Code: Select all

	-ArgumentList ($Computers, $SUFFIXES)
That's it!! The rest of your code should work fine.

Please let us know if these changes works for you.

:)
User avatar
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Re: Jobs and DGV

Post by MarvelManiac »

Thanks, I'll give this a try tonight.
One thing that comes to mind. I've seen that the ISE does not react the sameway as the console. Is there truth to this? I write 100% of my scripts in the ISE, then transfer them to PSS
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: Jobs and DGV

Post by mxtrinidad »

Good! Just keep in mind. ISE PowerShell host is not the same the SAPIEN PowerShell host as we build our own for our product.

Just let us know how you did with the script.

:)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs and DGV

Post by jvierra »

Here is a basic demo of how to dynamically update a DGV from a job tracker. It is really very easy to set up and use. As each result is received it is added to the DGV.

I also have a few other examples that are more complex but are designed to work with a SQLServer database.
Attachments
JobPingTest.psf
(35.45 KiB) Downloaded 153 times
User avatar
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Re: Jobs and DGV

Post by MarvelManiac »

Hello, I did want to provide an update as I'm still trying to understand why you guys are doing it two separate but similar ways.

I have noticed these run different on Windows 7 vs Windows 10.
For example, under Windows 10 it takes a few moments to start and by then I'm able to ping 60 or so machines
The progress bar will be complete but it's still finding PCs
Or Windows 10 will run very smooth and Windows 7 will throw 100's of errors
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs and DGV

Post by jvierra »

You have to look at my example carefully to understand why it works. It will work on any system. I have updated it due to one item that reported the wrong status. Run it with the array defined then add a couple of your systems.

Before moving on or making any changes you need to understand HOW it works.
Attachments
JobPingTest.psf
(23.53 KiB) Downloaded 119 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs and DGV

Post by jvierra »

I should also note that under Win7 there are display issues with the listbox. The code does work so ignore the look of the listbox.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs and DGV

Post by jvierra »

I found the mismatch and fixed it. Not sure why but loading from an array or file does not have the issue.
This topic is 5 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