Iterate through CSV for System.Diagnostics.Process object

Ask your 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.
This topic is 5 years and 6 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
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Iterate through CSV for System.Diagnostics.Process object

Post by njcappa »

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 124 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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.
This topic is 5 years and 6 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