PowerShell ISE | Multiple Ping

The Windows PowerShell Integrated Scripting Environment (ISE) is a graphical user interface and front-end hosting application for Windows PowerShell. The ISE enables developers to run PowerShell commands and create, test and refine PowerShell scripts without the need to operate directly in the traditional PowerShell command-line interface (CLI).


At first glance, PowerShell ISE is a convenient GUI for the PowerShell console. The ISE provides a variety of editing controls, user help and other ease-of-use features that aren't readily present in PowerShell. For example, the ISE supports multi-line editing, tab completion, syntax-based coloring, selective execution, context-sensitive help and multi-language support. Menu options and keyboard shortcuts in the ISE mimic many of the common tasks traditionally performed in the PowerShell console.


Advantages of PowerShell ISE:

- Time savings and reduced errors in script creation;

- Improved debugging and testing;

- Greater insight into related scripts, ...


Disadvantages of PowerShell ISE:

- Unnecessary complexity for certain tasks;

- Limited paging;

- Lack of support for certain legacy commands, ...


This is a small utility that allows you to easily ping multiple host names and IP addresses, and export the result in one file.

First of all, you need to create hosts.txt and enter all the IP addresses you need to respond to and run the script below.


Code:

$name=Get-content "C:\tmp\hosts.txt"
foreach($name in $name)
{
if(Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
Write-Host "$name is up" -ForegroundColor Green
$output+="$name is up!"+"`n"
}
else{
Write-Host "$name is down" -ForegroundColor Red
$output+="$name is down!"+"`n" }
}
$output | Out-File "C:\tmp\result-hosts.txt"
Start-Sleep -s 15

The result:

192.168.0.1 is up!
192.168.0.2 is up!
192.168.0.3 is down!
192.168.0.4 is up!
192.168.0.5 is down!

In the Windows folder (C:\tmp) you will have a new file with the output result of the script.



gif

12 views0 comments

Recent Posts

See All

Python | Getting pictures from Instagram

In this post you will learn how you can save pictures from Instagram account in your PC using Python. You just need to install "instalooter" into your Python packages and run the command. There are ma

Telegram message with Python

In this post I am showing how to send text message and photo from any computer to mobile telegram app. This is only few lines of code to send automatic message to smartphone from raspberry pi or from

Python | QR-Code

What is a QR-Code? A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a