Ping subnet based on syntax..?

By jcwfbi ·
trying to word this right,

What I would like to do is allow the user to enter a subnet and have all addresses in the subnet pinged for reply based on the syntax being correct and the routing table on the local machine be searched for the subnet as well,

Example if the user enters 10.0.1 the script says that is not a valid syntax for a subnet please try again,

however if they enter for example then the script attempts to check the subnet range if you will and ping all addressses, this would be an internal test only.

Essentially this would be something that would be run at the end of week or when starting the workweek to see if any systems appear offline.

Any thoughts on how this would have to be declared? Below is what I have so far:

Write-host -foregroundcolor green "Enter ip address range to search: " -nonewline

$a = Read-host

if ($a -notlike ""){

write-host -foregroundcolor red "Address context $a is not valid!"



else {

Write-Host ""

write-host -foregroundcolor blue "Address is $a"

ping $a"

I used as a way to just check that my if else was looking at $a. I believe ($a -notlike "") would need to be a wildcard though maybe with subnet range. Sorry if this is confusing. trying to get back into poweshell world. Any thoughts are appreciated.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums