Page 1 of 2

Jobs and DGV

Posted: Fri Aug 10, 2018 11:48 pm
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 166 times

Re: Jobs and DGV

Posted: Wed Aug 15, 2018 6:05 am
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 131 times

Re: Jobs and DGV

Posted: Wed Aug 15, 2018 7:30 pm
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.

:)

Re: Jobs and DGV

Posted: Thu Aug 16, 2018 7:36 am
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

Re: Jobs and DGV

Posted: Thu Aug 16, 2018 8:42 am
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.

:)

Re: Jobs and DGV

Posted: Sat Aug 18, 2018 9:12 am
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.

Re: Jobs and DGV

Posted: Mon Aug 20, 2018 1:12 pm
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

Re: Jobs and DGV

Posted: Mon Aug 20, 2018 1:31 pm
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.

Re: Jobs and DGV

Posted: Mon Aug 20, 2018 1:35 pm
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.

Re: Jobs and DGV

Posted: Mon Aug 20, 2018 1:42 pm
by jvierra
I found the mismatch and fixed it. Not sure why but loading from an array or file does not have the issue.