Highlighted
Expert
Expert

general powershell question on start-job

Jump to solution

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
Highlighted
User Moderator
User Moderator

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
Highlighted
User Moderator
User Moderator

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
Highlighted
Expert
Expert

Thanks LucD. Script execution speed improved after setting throttlelimit

Regards Vineeth.K
0 Kudos