Solved

I am looking for a power shell script to ask the user for a range and ping and report back hostname

Posted on 2015-02-20
2
110 Views
Last Modified: 2015-02-21
I am looking for a power shell script to ask the user for a range and ping and report back hostname

Thanks for the help!!!!!!
0
Comment
Question by:NAMEWITHELD12
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40622650
Hi there,

This may not be the most efficient way to do this, but it does work.  Try out this Powershell code:
$startrange = read-host "Enter a start IP"
$endrange = read-host "Enter an end IP"
$startsubnet = "$($startrange.Split(".")[0]).$($startrange.Split(".")[1]).$($startrange.Split(".")[2])."
$endsubnet = "$($endrange.Split(".")[0]).$($endrange.Split(".")[1]).$($endrange.Split(".")[2])."
if ($startsubnet -eq $endsubnet) {
    $startip = $($startrange.Split(".")[3])
    $endip = $($endrange.Split(".")[3])
    $startip..$endip | foreach{test-connection -ComputerName $startsubnet$_ -count 1} | select -expandproperty ipv4address | select -expandproperty ipaddresstostring | foreach{[System.Net.Dns]::GetHostByAddress("$_")}
} else {
    write-host "Start subnet was not the same as the end subnet"
}

Open in new window


Regards,

Rob.
0
 
LVL 1

Author Closing Comment

by:NAMEWITHELD12
ID: 40623834
Thanks tons !!!

I want to learn more about this and will post another question now about this !

THANKS AGAIN !!!!!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question