• Home
  • About 404TS
  • Contact

404 Tech Support

Where IT Help is Found

  • Articles
    • Code
    • Entertainment
    • Going Green
    • Hardware, Gadgets, and Products
    • Management
    • Network
    • News
    • Operating Systems
    • Security and Privacy
    • Software
    • System Administration
    • Talking Points
    • Tech Solutions
    • Web
    • Webmaster
  • Reviews
  • Media
    • Infographics
    • Videos
  • Tech Events
  • Tools
    • How do I find my IP address?
    • Browser and plugin tests
  • Get a Technical Consultation
You are here: Home / Articles / Code / PowerShell script to ping multiple computers

PowerShell script to ping multiple computers

2015-03-23 by Jason

A recent project involved tracking down some old computers. To find them, we only had the computer name to start. We came up with a plan to try to find out more information about the computers by accessing the hidden C$ share on the computers. This quickly became time-consuming and frustrating as many of the computers were not even pingable, as they were most likely not powered on at the time we were trying to connect to them.

To speed things up, we could ping each computer first and only try the more time-consuming C$ share approach to those that responded to the ping. Since these computers might be powered on at different timesĀ of the day, a script made the most sense to save from typing everything out each time.

This PowerShell script reads from a text file ping.txt with each computer name on its own line and then uses test-connection to ping the computer. Ping.txt should reside in the same folder as the script. The computers that are successfully pinged are pinged one more time to get their IP address (more information to use in tracking them down) and are logged in a text file to the desktop as text file named pingable_[timestamp]. The computers that do not reply to the ping are logged to a text file on the desktop named notpingable_timestamp.

I considered making it a circular log so the non-responding computers would be filtered and ready for the next round of running the script but kept with this direction to keep things more straight-forward.

Note to replace .domain.fqdn with your own fully qualified domain name, so it is appended to each computer name.

# Jason Hamilton
# https://www.404TechSupport.com/
# Ping a number of computers and report the successful ones.

# List computer name (not FQDN) in ping.txt in the same directory as this script
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
Write-Host $ScriptPath
$PCs = Get-Content $ScriptPathping.txt
$timestamp = get-date -f "MMddyyyyHHmm"
$successlog = [string]::concat($Env:userprofile, "Desktoppingable_", $timestamp,".txt")
$faillog = [string]::concat($Env:userprofile, "Desktopnotpingable_", $timestamp,".txt")
Clear-host
Write-Host "Testing connection to computers listed in ping.txt"
Write-Host ""

# loop through above array of each computer and test pinging to them.
Foreach ($i in $PCs)
{
$PC = $i+".domain.fqdn"

$pingable = test-connection -ComputerName $PC -Count 2 -quiet

if ($pingable) {
$pingable2 = test-connection -ComputerName $PC -Count 1

#List successful connections
Write-Host $PC "is pingable with" $pingable2.IPV4Address
$report = [string]::concat($PC, " is pingable with ", $pingable2.IPV4Address)
$report | Out-File -FilePath $successlog -Append

} else {
Write-Host $PC "was not pingable."
$report = [string]::concat($PC, " was not pingable.")
$report | Out-File -FilePath $faillog -Append
}
}

Write-Host ""
#Equivalent to Pause
Read-Host 'Press Enter to continue...' | Out-Null

After the script completes going through the list of computers, you would be able to take the pingable text file and connect to those C$ shares and drill down to the user profile folder to find out who has logged in to the computer recently and hopefully help locate the computer.

Filed Under: Code

Trending

  • How to configure Windows 8 to auto login
    In Tech Solutions
  • Google Releases Google Cloud Print Beta To The Public
    In Hardware, Gadgets, and Products, Software
  • Disable Firefox from removing the http:// in the address bar
    In Software, Tech Solutions

Latest Media Posts

Find Out Where To Download SNES ROMs

Find Out Where To Download SNES ROMs

Multifunctional Video Conversion Tools – Wondershare Video Converter

Multifunctional Video Conversion Tools – Wondershare Video Converter

  • Popular
  • Latest
  • Today Week Month All
  • Access to the resource [servershare] has been disallowed Access to the resource [servershare] has been disallowed
  • Read the Event Logs on Windows Server Core Read the Event Logs on Windows Server Core
  • Increase IIS Private Memory Limit to improve WSUS availability Increase IIS Private Memory Limit to improve WSUS availability
  • How to ‘Unblock’ multiple files at a time with PowerShell How to 'Unblock' multiple files at a time with PowerShell
  • Setup your DFS namespace with DNS for compatibility in a mixed environment Setup your DFS namespace with DNS for compatibility in a mixed environment
  • How Virtual Reality Supports Mental Health Therapy How Virtual Reality Supports Mental Health Therapy
  • Key Strategies of Successful Coin Listing on Exchange Key Strategies of Successful Coin Listing on Exchange
  • Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting
  • Making Distributed Software Development Work: Strategies and Best Practices for Managing Remote Teams Making Distributed Software Development Work: Strategies and Best Practices for Managing Remote Teams
  • customer contactless payment for drink with mobile phon at cafe counter bar,seller coffee shop accept payment by mobile.new normal lifestyle concept The Latest Innovations In Payment Technology
Ajax spinner

Elevator Pitch

404 Tech Support documents solutions to IT problems, shares worthwhile software and websites, and reviews hardware, consumer electronics, and technology-related books.

Subscribe to 404TS articles by email.

Recent Posts

  • How Virtual Reality Supports Mental Health Therapy
  • Key Strategies of Successful Coin Listing on Exchange
  • Keeping Your Mac Healthy: A Comprehensive Guide to Maintenance and Troubleshooting

Search

FTC Disclaimer

404TechSupport is an Amazon.com affiliate; when you click on an Amazon link from 404TS, the site gets a cut of the proceeds from whatever you buy. This site also uses Skimlinks for smart monetization of other affiliate links.
Use of this site requires displaying and viewing ads as they are presented.

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in