---
# source: blog-content: posts/en/powershell-script-to-test-multiple-ip-addresses.md
# route:  /en/insights/powershell-script-to-test-multiple-ip-addresses/
title: PowerShell Script to test multiple IP Addresses
date: 2024-02-04
author: dario-doerflinger
locale: en
summary: This small scriptlet reads a CSV with a column called “IPaddress” and pings its way through the addresses. In a lot of projects I have to confirm that a set of IPs is free.
capabilities: [automation]
vendors: [vmware]
series: scripting
hero: /blog-assets/powershell-script-to-test-multiple-ip-addresses/hero.webp
migrated: 2026-08-24
translationReviewed: false
draft: false
---

This small scriptlet reads a CSV with a column called "IPaddress" and pings its way through the addresses.

In a lot of projects I have to confirm that a set of IPs is actually free. This scriptlet colour-codes the result and can be re-run whenever you need it, at almost no effort.

```powershell
Param(
[Parameter(Mandatory=$true, position=0)][string]$csvfile
)
$ColumnHeader = "IPaddress"
Write-Host "Reading file" $csvfile
$ipaddresses = import-csv $csvfile | select-object $ColumnHeader
Write-Host "Started Pinging.."
foreach ($ip in $ipaddresses) {
    if (test-connection $ip.("IPAddress") -count 1 -quiet) {
        write-host $ip.("IPAddress") "Ping succeeded." -foreground green
    } else {
        write-host $ip.("IPAddress") "Ping failed." -foreground red
    }
}
Write-Host "Pinging Completed."
```
