I wrote a PowerShell script! :D It's super exciting - it makes a list of all the IPs in an IPv4 subnet and writes them to a text file! :D (I'm sure this accomplishment would not impress anyone with any non-zero amount of expertise in scripting, but this is my first time writing a script, gotta start with the small stuff.) The script can easily be
(
Read more... )
Comments 5
now modify it to run a ping test on each of those IP addresses, outputting the results to a file, and then concatenating each output to the tail end of said file. :D
Reply
Reply
$3rdOctet=232
while ($3rdOctet -lt 240)
{for ($4thOctet=0; $4thOctet -lt 256; $4thOctet++)
{if ("$3rdOctet.$4thOctet" -eq "239.255")
{write-output "Done!"}
elseif ("$3rdOctet.$4thOctet" -eq "232.0")
{write-output "Subnet prefix skipped!" | out-null}
else
{ping -n 1 "10.198.$3rdOctet.$4thOctet" | out-file c:\temp.txt;
$temp = get-content c:\temp.txt;
if ($temp[6] -match "Reply from 10.198.$3rdOctet.$4thOctet")
{$pingResponse = "Yes"}
else {$pingResponse = "No"};
out-file -append c:\IPs.txt -inputobject "10.198.$3rdOctet.$4thOctet, $pingResponse"}};
if ($4thOctet=255)
{$3rdOctet++};
if ($4thOctet=255)
{$4thOctet=0}
}
Reply
Reply
Leave a comment