---
id: AA-01384
title: "Testing Device Access using Ping Script"
url: http://netaphor.com/kb/AA-01384/testing-device-access-using-ping-script
product: "General"
type: "How-to & configuration"
updated: 2024-04-25
access: public
---


# Testing Device Access using Ping Script

It is sometimes helpful to identify IP addresses that can or cannot be pinged. This article describes how to use PowerShell to ping devices and identify those that respond successfully and those that do not.

- Extract the content of the zip file attached at the bottom of this article.
- Edit the **ipaddresses.txt** file
- Edit the file paths in **PingScript.ps1** and save the file
- Open PowerShell as administrator
- Set the Execution policy
- Run PingScript.ps1

## Edit PowerShell Script

Open the **PingScript.ps1** file and edit the location of the ipaddresses.txt file and the location where the results file is stored.

$ipList = "C:\\Users\\Ken\\Desktop\\PingScript\\ipaddresses.txt"

$outputCsv = "C:\\Users\\Ken\\Desktop\\PingScript\\ping_results.csv"

## Edit IP Address File

The **ipaddresses.txt** file contains a list of IP addresses that the script will ping. Open this file in Notepad and enter your IP addresses, one per line, and save the file. The entries can be IP addresses or DNS names.

ipaddresses.txt file content. One IP address or DNS name per line

10.0.3.84

172.16.5.5

prot3fj.agent.com

netaphor.com

10.0.1.237

## Pinging IP Addresses

Once ready, run the **PingScript.ps1** from an elevated PowerShell prompt as shown below. The script shows each address as it is being pinged and stores the result of the operation in the **ping_results.txt** file.

![](http://netaphor.com/kb/media/AA-01384/embedded-01.png)

It may be necessary to set the execution policy to run **PingScript.ps1**. Execute the following command from an elevated PowerShell window for all \[a\]:

### Set-ExecutionPolicy Unrestricted

## Review Results

Once the **PingScript.ps1** completes execution, open the output file to observe the results. The example below illustrates that each IP address, status, and latency are displayed.

![](http://netaphor.com/kb/media/AA-01384/embedded-02.png)

Download the attached file and edit to test ping in your environment.

## Downloads

- [PingScript.zip](http://netaphor.com/kb/files/AA-01384/PingScript.zip)
