Iterate through CSV for System.Diagnostics.Process object

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
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.
Locked
User avatar
njcappa
Posts: 66
Joined: Wed May 04, 2016 6:50 am

Iterate through CSV for System.Diagnostics.Process object

Post by njcappa » Mon Sep 17, 2018 8:38 am

Hi All,

I'm attempting to use the attached psf (which invokes the System.Diagnostics.Process object), to run an exe and output the results. In the example psf, the "$process.StartInfo.Arguments" value calls arguments for ping, but what actually I need to do is to have it call a value from a foreach object which imports a CSV file.

Usually, I'd just type this:

Code: Select all

$Images = Import-csv $InputFile | ForEach-Object { }
and in the brackets, I'd call the EXE and give it the $_. data from the CSV. This is what my code does now, but it also locks up the form which is something I want to avoid.

Is the above possible using the diagnostic process object?

thanks!
Attachments
Demo-Capture StandardOutAsync.psf
(17.2 KiB) Downloaded 33 times

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

Re: Iterate through CSV for System.Diagnostics.Process object

Post by jvierra » Mon Sep 17, 2018 1:32 pm

Hi njcappa,

You have posted the code from another thread that runs a process asynchronously. You need to post an example of your code.

Also not that a process is not a good way to execute PowerShell code. It is good for non-PS programs. For PS code use a job, workspace or runspace.

Locked