Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This Powershell script is used to ping a set range of IP address with a variable in the address.
- #
- # Based on the input the user will ping all IP addresses in the range of 10.2.X.200 through 10.2.X.210.
- # This just happens to be the range of IP addresses we allow for DHCP at our locations.
- # For my purposes at my workplace the Plant # corresponds to the 3rd byte of an IP Address (the variable here).
- # This can be altered to fit your needs.
- #
- # This script is also written to be ran from a shortcut.
- write-host "This Script will Ping IP Addresses .200 through .210
- and look for connectivity at a given Plant." -BackgroundColor Gray -ForegroundColor Blue
- write-host ""
- $plant = Read-Host 'What Plant will we be testing? (Please enter a numeric value)'
- write-host ""
- $servers = "10.2.$plant.200","10.2.$plant.201","10.2.$plant.202","10.2.$plant.203","10.2.$plant.204","10.2.$plant.205","10.2.$plant.206","10.2.$plant.207","10.2.$plant.208","10.2.$plant.209","10.2.$plant.210"
- Foreach($s in $servers)
- {
- if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))
- {
- write-host "Problem communicating with $s" -foregroundcolor "yellow"
- if(!(Test-Connection -Cn $s -BufferSize 16 -Count 1 -ea 0 -quiet))
- {write-host "No device detected at $s" -foregroundcolor "red"}
- ELSE {write-host "Resolved problem connecting to $s" -foregroundcolor "green"} #end if
- } # end if
- ELSE {write-host "Device successfully detected at $s" -foregroundcolor "green"} #end foreach
- } # end foreach
- write-host "End of Script." -BackgroundColor Black -ForegroundColor Black
- Start-Sleep -s 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement