VMware Cloud Community
vin01
Expert
Expert
Jump to solution

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
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The ThrottleLimit parameter on the Foreach-Object cmdlet defaults to 5.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

The ThrottleLimit parameter on the Foreach-Object cmdlet defaults to 5.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vin01
Expert
Expert
Jump to solution

Thanks LucD. Script execution speed improved after setting throttlelimit

Regards Vineeth.K
0 Kudos