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.
User avatar
MarvelManiac
Posts: 63
Joined: Mon May 01, 2017 8:28 pm

Jobs and DGV

Post by MarvelManiac » Fri Aug 10, 2018 11:48 pm

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 16 times

User avatar
mxtrinidad
Site Admin
Posts: 209
Joined: Sun Mar 03, 2013 12:42 pm

Re: Jobs and DGV

Post by mxtrinidad » Wed Aug 15, 2018 6:05 am

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 13 times

User avatar
mxtrinidad
Site Admin
Posts: 209
Joined: Sun Mar 03, 2013 12:42 pm

Re: Jobs and DGV

Post by mxtrinidad » Wed Aug 15, 2018 7:30 pm

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
Joined: Mon May 01, 2017 8:28 pm

Re: Jobs and DGV

Post by MarvelManiac » Thu Aug 16, 2018 7:36 am

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
Site Admin
Posts: 209
Joined: Sun Mar 03, 2013 12:42 pm

Re: Jobs and DGV

Post by mxtrinidad » Thu Aug 16, 2018 8:42 am

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.

:)

User avatar
jvierra
Posts: 12677
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs and DGV

Post by jvierra » Sat Aug 18, 2018 9:12 am

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 10 times

User avatar
MarvelManiac
Posts: 63
Joined: Mon May 01, 2017 8:28 pm

Re: Jobs and DGV

Post by MarvelManiac » Mon Aug 20, 2018 1:12 pm

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

User avatar
jvierra
Posts: 12677
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs and DGV

Post by jvierra » Mon Aug 20, 2018 1:31 pm

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 7 times

User avatar
jvierra
Posts: 12677
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs and DGV

Post by jvierra » Mon Aug 20, 2018 1:35 pm

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.

User avatar
jvierra
Posts: 12677
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs and DGV

Post by jvierra » Mon Aug 20, 2018 1:42 pm

I found the mismatch and fixed it. Not sure why but loading from an array or file does not have the issue.

Locked