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
The ThrottleLimit parameter on the Foreach-Object cmdlet defaults to 5.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The ThrottleLimit parameter on the Foreach-Object cmdlet defaults to 5.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD. Script execution speed improved after setting throttlelimit