Fast-Ping Sweep (recommendations or tricks)
CountDClemo opened this issue · 2 comments
Goal:
I am trying to only use PowerShell to conduct a ping sweep and I want to perform the fastest ping sweep possible.
Research:
I found a quick single line script from “https://learn-powershell.net/2011/01/31/quick-hits-ping-sweep-one-liner/” and leveraged invoke-parallel in place of foreach (%). Also, I added Where-Object {$_ -like "True"} to filter out the false and/or non-pingable IPs.
Request:
So far, I can ping sweep a /24 in about 20 to 25 seconds. I want to know if anyone else has any recommendations or tricks to cut the time down (if possible) only using PowerShell.
Reason:
I am looking into building a branch with a PowerShell based GUI that leverages invoke-parallel to ping sweep subnets and port scan live IPs to validate findings of other commercial and/or opensource networking products.
Script block:
#Very short Script block used with invoke-parallel function
#Requires change of the IP ranges to meet pinged area subnet.
#There are wildcards on each side of the word True. See bottom of the attached Fast-Ping.txt
1..254 |
Invoke-Parallel {
$IPsping = '192.168.3.'
"$IPsping$($): $(Test-Connection -count 1 -comp $IPsping$($) -quiet)" |
Where-Object {$_ -like "True"}}
Hi
Try this custom class from Trevor Jones.
https://smsagent.blog/posh-5-custom-classes/power-ping/
Nils
nilssol,
Thank you,
I can see some parts of the script that I can pull from to target IP ranges vs get-adcomputer. Also, I see the function "Invoke-MultiThreadedCommand" can provide a similar result to invoke-parallel. Very interesting and again think you for the info very helpful.