Reply to Message

View discussion in a popup

Replying to:
vin01
Expert
Expert

general powershell question on start-job

I am trying to telnet 4125 Ips using Test-NetConnection. The below is the script. Here I used the script to execute in Parallel as a job. However After executing the job when I verified the child jobs only 5 jobs are running at single point of time and other jobs are in not started state.

My question is can we increase the execution process of child jobs to more then 5?

$ipslistcsv=Import-Csv -Path C:\Users\testuser\Desktop\VLANSORTEDLIST.csv -UseCulture

$scriptasjob= $ipslistcsv | ForEach-Object -Parallel {

        if ((Test-NetConnection -ComputerName $_.IP -Port 3389 -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded -eq $true) {

            "Connection establisted sucessfully over port 3389 for IP $($_.IP)"  

        }

        elseif ((Test-NetConnection -ComputerName $_.IP -Port 22 -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded -eq $true) {

            "Connection establisted sucessfully over port 22 for IP $($_.IP)"   

        }

        else {

            "No Connection establised for IP $($_.IP)"

        }

    } -AsJob

(Get-Job -Id $scriptasjob.id).ChildJobs

pastedImage_2.png

Regards Vineeth.K
Reply
0 Kudos