<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>youdidwhatwithtsql.com &#187; Ping</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/tag/ping/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ping all Domain Computers with Powershell</title>
		<link>http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209</link>
		<comments>http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:52:29 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Ping]]></category>
		<category><![CDATA[Powershell Scripting]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209</guid>
		<description><![CDATA[Here’s a Powershell script that can ping all computers that are in your domain. All computers registered in AD will be pinged, including ones long dead, so this script may be useful for figuring out what is still active on your network. There’s nothing to configure on this script so it should be good to [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209">Ping all Domain Computers with Powershell</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Here’s a <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">Powershell</a> script that can <a href="http://en.wikipedia.org/wiki/Ping" target="_blank">ping</a> all computers that are in your <a href="http://en.wikipedia.org/wiki/Windows_Server_domain" target="_blank">domain</a>. All computers registered in <a href="http://en.wikipedia.org/wiki/Active_Directory" target="_blank">AD</a> will be pinged, including ones long dead, so this script may be useful for figuring out what is still active on your network.</p>
<p>There’s nothing to configure on this script so it should be good to run untouched on any <a href="http://en.wikipedia.org/wiki/Windows_Server_domain" target="_blank">domain</a>. The console will output results of the <a href="http://en.wikipedia.org/wiki/Ping" target="_blank">ping</a> but two text files will be created in your user profile folder, <strong>C:\Users\Rhys </strong>on my Windows 7 laptop. The text files will be named in the following&#160; formats;</p>
<ul>
<li>alive yyyyMMddhhmmss.csv – All computers that responded to the ping.</li>
<li>dead yyyyMMddhhmmss.csv – All computers that didn’t respond to the ping.</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p209code2'); return false;">View Code</a> POWERSHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2092"><td class="code" id="p209code2"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Code adapted / expanded from http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov06/hey1109.mspx</span>
<span style="color: #800080;">$datetime</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span> <span style="color: #008080; font-style: italic;">-Format</span> <span style="color: #800000;">&quot;yyyyMMddhhmmss&quot;</span>;
<span style="color: #800080;">$strCategory</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;computer&quot;</span>;
&nbsp;
<span style="color: #008000;"># Create a Domain object. With no params will tie to computer domain</span>
<span style="color: #800080;">$objDomain</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.DirectoryEntry;
&nbsp;
<span style="color: #800080;">$objSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.DirectorySearcher; <span style="color: #008000;"># AD Searcher object</span>
<span style="color: #800080;">$objSearcher</span>.SearchRoot <span style="color: pink;">=</span> <span style="color: #800080;">$objDomain</span>; <span style="color: #008000;"># Set Search root to our domain</span>
<span style="color: #800080;">$objSearcher</span>.<span style="color: #0000FF;">Filter</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(objectCategory=$strCategory)&quot;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008000;"># Search filter</span>
&nbsp;
<span style="color: #800080;">$colProplist</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;name&quot;</span>;
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$colPropList</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$objSearcher</span>.PropertiesToLoad.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$colResults</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008000;"># Add column headers</span>
<span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\alive $datetime.csv&quot;</span> <span style="color: #800000;">&quot;computer,ipAddress&quot;</span>;
<span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\dead $datetime.csv&quot;</span> <span style="color: #800000;">&quot;computer,ipAddress&quot;</span>;
&nbsp;
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objResult</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$colResults</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$objComputer</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objResult</span>.Properties;
	<span style="color: #008000;"># Get the computer ping properties</span>
	<span style="color: #800080;">$computer</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objComputer</span>.name;
	<span style="color: #800080;">$ipAddress</span> <span style="color: pink;">=</span> <span style="color: #800080;">$pingStatus</span>.ProtocolAddress;
	<span style="color: #008000;"># Ping the computer</span>
	<span style="color: #800080;">$pingStatus</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-WmiObject</span> <span style="color: #008080; font-style: italic;">-Class</span> Win32_PingStatus <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: #800000;">&quot;Address = '$computer'&quot;</span>;
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$pingStatus</span>.StatusCode <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Green  <span style="color: #800000;">&quot;Reply received from $computer.&quot;</span>;
		<span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\alive $datetime.csv&quot;</span> <span style="color: #800000;">&quot;$computer,$ipAddress&quot;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Red <span style="color: #800000;">&quot;No Reply received from $computer.&quot;</span>;
		<span style="color: #008080; font-weight: bold;">Add-Content</span> <span style="color: #800000;">&quot;$Env:USERPROFILE\dead $datetime.csv&quot;</span> <span style="color: #800000;">&quot;$computer,$ipAddress&quot;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2009/06/image22.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Ping all domain computers with Powershell" border="0" alt="image thumb22 Ping all Domain Computers with Powershell" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2009/06/image-thumb22.png" width="644" height="327" /></a></p>
<p><map name='google_ad_map_209_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/209?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_209_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=209&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fping-all-domain-computers-with-powershell%2F209' title="Ping all Domain Computers with Powershell" alt=" Ping all Domain Computers with Powershell" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209">Ping all Domain Computers with Powershell</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

