Skip to main content

PS | Ping an entire subnet

Hello Guys,

Just wanted to update my notes with this small script but with big use. You can initiate and save entire output in a file with the help of below lines-

#start here
$subnet = "172.26.193"   #Just mention first three octet of any subnet
$start = 1
$end = 254  #Modify the end IP as per your requirement
$ping = 1
$OutPath ="C:\Temp\172.26.193"    #Modify the file location as per your wish and then run into guys!

While ($start -le $end) {
$IP = "$subnet.$start"
$Test = Test-Connection -ComputerName $IP -count $ping -Quiet
Write-Host "$IP,$Test"
Add-Content -LiteralPath $OutPath -Value "$IP,$Test"
$start++
}
#End here



Thank you,
vCloudNotes

Comments

Popular posts from this blog

Network Migration | VLAN to VXLAN

NSX-T | Getting Started with PowerCLI

Automate Power on Operations using PS

NSX-T | Security