<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.mikebeane.com/index.php?action=history&amp;feed=atom&amp;title=Powershell%3A_Ping_Stuff</id>
	<title>Powershell: Ping Stuff - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.mikebeane.com/index.php?action=history&amp;feed=atom&amp;title=Powershell%3A_Ping_Stuff"/>
	<link rel="alternate" type="text/html" href="https://www.mikebeane.com/index.php?title=Powershell:_Ping_Stuff&amp;action=history"/>
	<updated>2026-08-07T06:14:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://www.mikebeane.com/index.php?title=Powershell:_Ping_Stuff&amp;diff=1982&amp;oldid=prev</id>
		<title>Rabbi Bob: Created page with &quot;Category:Powershell Category:Weblog-2026-08  Provide a list of IP addresses, run the script.  Checks DNS and outputs a results file.   =Code= &lt;pre&gt; $deviceNames = Get-Content &quot;devices.txt&quot;  $results = @()  foreach ($name in $deviceNames) {   $status = &quot;Unknown&quot;      try {     # Attempt to resolve DNS     [System.Net.Dns]::GetHostEntry($name)     $status = &quot;Resolving...&quot;          # Check if device pings (up to 4 attempts with 1 second timeout)     if (Test-Connect...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.mikebeane.com/index.php?title=Powershell:_Ping_Stuff&amp;diff=1982&amp;oldid=prev"/>
		<updated>2026-08-06T19:54:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php/Category:Powershell&quot; title=&quot;Category:Powershell&quot;&gt;Category:Powershell&lt;/a&gt; &lt;a href=&quot;/index.php?title=Category:Weblog-2026-08&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Weblog-2026-08 (page does not exist)&quot;&gt;Category:Weblog-2026-08&lt;/a&gt;  Provide a list of IP addresses, run the script.  Checks DNS and outputs a results file.   =Code= &amp;lt;pre&amp;gt; $deviceNames = Get-Content &amp;quot;devices.txt&amp;quot;  $results = @()  foreach ($name in $deviceNames) {   $status = &amp;quot;Unknown&amp;quot;      try {     # Attempt to resolve DNS     [System.Net.Dns]::GetHostEntry($name)     $status = &amp;quot;Resolving...&amp;quot;          # Check if device pings (up to 4 attempts with 1 second timeout)     if (Test-Connect...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Powershell]]&lt;br /&gt;
[[Category:Weblog-2026-08]]&lt;br /&gt;
&lt;br /&gt;
Provide a list of IP addresses, run the script.  Checks DNS and outputs a results file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Code=&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$deviceNames = Get-Content &amp;quot;devices.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
$results = @()&lt;br /&gt;
&lt;br /&gt;
foreach ($name in $deviceNames) {&lt;br /&gt;
  $status = &amp;quot;Unknown&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  try {&lt;br /&gt;
    # Attempt to resolve DNS&lt;br /&gt;
    [System.Net.Dns]::GetHostEntry($name)&lt;br /&gt;
    $status = &amp;quot;Resolving...&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    # Check if device pings (up to 4 attempts with 1 second timeout)&lt;br /&gt;
    if (Test-Connection -ComputerName $name -Count 1 -Quiet) {&lt;br /&gt;
      $status = &amp;quot;Up&amp;quot;&lt;br /&gt;
    } else {&lt;br /&gt;
      $status = &amp;quot;Down&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  } catch {&lt;br /&gt;
    # Handle DNS resolution failure&lt;br /&gt;
    $status = &amp;quot;NO DNS&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # Create a custom object for each device&lt;br /&gt;
  $result = New-Object PSObject -Property @{&lt;br /&gt;
    Name = $name&lt;br /&gt;
    Status = $status&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Add object to results array&lt;br /&gt;
  $results += $result&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Export results to CSV&lt;br /&gt;
$results | Export-Csv -Path &amp;quot;results.csv&amp;quot; -NoTypeInformation -Force&lt;br /&gt;
&lt;br /&gt;
Write-Host &amp;quot;Results exported to &amp;#039;results.csv&amp;#039;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rabbi Bob</name></author>
	</entry>
</feed>