Jump to content

Recommended Posts

Posted

I have a lot of IP address that I need to check which I have stored in a CSV file. I already have a script which performs an API call and gets information that each group IP is in - this is run using a foreach loop to check each IP at one 1 time before moving onto the next. This works fine and for most of my work it is no problem, but due to the number of groups it needs to check against the script take a long time to check. I now have a very large csv file which I want to run and this is going to take a very long time to run if I just use forloop so I am trying to speed it up and run multiple jobs at the same time. If I understand correctly I can do this by using Start-job.

So I am making an API call where I am passing some the IP variable to the command. However, what I need to do is take the IP from the input & add the result from the start-job.

For example

csv file would contain IP

1.1.1.1

1.1.1.2

 

I need to get the output so it reads

1.1.1.1, Group 1, Group 2

1.1.1.2, Group 1, Group 4

 

At the moment I just get the result from the start-job

Group 1, Group 2

Group 1, Group 4

 

 

I am using the following to get the results - but this get the results from the command in the start-job, how can I then also pull the data from the input csv.

# Process the resultsforeach($job in Get-Job){ $result = Receive-Job $job Write-Host $result}

 

In my original script I do this during the foreach loop as I can access both the csv data and the PS command being run against the IP at the same time. How would I go about using data from the csv and join the result from the job to it?

  • 2 weeks later...
Posted
I haven't yet. As I understand this needs PS ver7? If so I need to upgrade PS ver and do some more testing. As it stands I'm actually leaving this job soon so I probably won't get time to complete this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...