<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx</link><description>Summary: Learn how to use Windows PowerShell to query Active Directory for computers, ping for status, and display in green/red.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3467830</link><pubDate>Tue, 29 Nov 2011 11:08:16 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3467830</guid><dc:creator>Meg Challinor</dc:creator><description>&lt;p&gt;Hi guys,&lt;/p&gt;
&lt;p&gt;I work on a rather large estate and I&amp;#39;m wondering if it would be possible to make the ping check in this script multi-threaded so that effectively it would be pinging 3-5 machines at once instead of 1, wait for a reply, next 1, wait for a reply... etc.&lt;/p&gt;
&lt;p&gt;If so how would I even start to go about that?!&lt;/p&gt;
&lt;p&gt;Thanks guys, love the blog.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3467830" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466701</link><pubDate>Tue, 22 Nov 2011 17:30:56 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466701</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@JV you are correct; Test-Connection is introduced in PowerShell 2.0, and the -quiet switch should force the cmdlet to return a boolean value that indicates return or no return.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466701" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466687</link><pubDate>Tue, 22 Nov 2011 16:57:09 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466687</guid><dc:creator>JV</dc:creator><description>&lt;p&gt;All&lt;/p&gt;
&lt;p&gt;Test-Connnection has a switch called &amp;#39;Quiet&amp;#39;. &amp;nbsp;It is defined as setting no output on the command and also forcing a boolean to be returned. Test-Connection is new for PowerShell 2.0.&lt;/p&gt;
&lt;p&gt;Type: help Test-Connection -para q*&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466687" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466686</link><pubDate>Tue, 22 Nov 2011 16:53:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466686</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Tony there is nothing wrong with using an array in this circumstance. In fact, an array is a great data structure. You are pretty much limited by memory, but other than that it works fine. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466686" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466685</link><pubDate>Tue, 22 Nov 2011 16:50:47 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466685</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Benjamin Ross I like using the .NET classes to do a DNS lookup ... this is a nice technique ... and a great idea.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466685" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466684</link><pubDate>Tue, 22 Nov 2011 16:48:47 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466684</guid><dc:creator>Ed Wilson </dc:creator><description>&lt;p&gt;@Jacques @Klaus Schulte hmmmm.... I might have been using my laptop that has a different version of PowerShell installed on it ... they are both the same from the outside. I just tested this on my desktop computer that definately has PowerShell 2.0 installed on it, and it does return a Boolean ... So you are right, the string check is not required. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466684" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466682</link><pubDate>Tue, 22 Nov 2011 16:44:01 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466682</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@Klaus Schulte Yes, the Scripting Wife and I had a great time in sunny California. We had a bit of time to go to a couple of museums while we were there. I try to give the scripts a descriptive name as it makes them easier to find ... but it does lead to long names :-) You are completely right about possibly &amp;quot;messing&amp;quot; up the variable for another script ... generally for me that is not a problem. The problem instead arises when I am using the Windows PowerShell ISE, and I have it open all day while working on lots of different scripts. I do tend to use the same type of variable names, and therefore I sometimes get into problem with variables that have a left over value; or even when I am writing the script its previous variables linger with old values. It is a good practice in such situations to initialize the variables (such as setting to 0 or $null, or to an initial value) rather than hoping it has not been used. Variable Scoping can definately help with this, but generally for simple scripts I do not bother. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466682" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466648</link><pubDate>Tue, 22 Nov 2011 14:12:54 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466648</guid><dc:creator>Tony</dc:creator><description>&lt;p&gt;I gather the list of computers, ping each, if the computer is offline I stick it in an array list then run get-adcomputer again to find out the lastlogontime for the offline computer array. &amp;nbsp;Does it make sense to use an array list in this instance? &amp;nbsp;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466648" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466494</link><pubDate>Mon, 21 Nov 2011 19:28:30 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466494</guid><dc:creator>Benjamin Ross</dc:creator><description>&lt;p&gt;Very nice Ed. As my predominant use for this is in a production, I tend to do a .net call to the System.Net.DNS and lookup via hostname. For us this tends to afford us the opportunity to catch systems that may be offline and catch systems that have registered. We do have aging and scavenging turned on so it helps give us a time based stamp of whether a system has been seen on the network.&lt;/p&gt;
&lt;p&gt;foreach ($comp in $allcomputers){&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;$dns = $([system.net.dns]::gethostbyname($comp.DnsName))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ($dns -ne $null){&lt;/p&gt;
&lt;p&gt;			$computers += $comp&lt;/p&gt;
&lt;p&gt;			$dns = $null}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elseif ($dns -eq $null){&lt;/p&gt;
&lt;p&gt;			$nodns += $comp&lt;/p&gt;
&lt;p&gt;			$dns = $null}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466494" width="1" height="1"&gt;</description></item><item><title>re: Query AD for Computers and Use Ping to Determine Status</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/19/query-ad-for-computers-and-use-ping-to-determine-status.aspx#3466282</link><pubDate>Sun, 20 Nov 2011 10:41:54 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3466282</guid><dc:creator>Klaus Schulte</dc:creator><description>&lt;p&gt;@Jacques&lt;/p&gt;
&lt;p&gt;same result here!&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t check the type but we can see this:&lt;/p&gt;
&lt;p&gt;PS C:\Users\klaus&amp;gt; $rtn.gettype()&lt;/p&gt;
&lt;p&gt;IsPublic IsSerial Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BaseType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;-------- -------- ---- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;True &amp;nbsp; &amp;nbsp; True &amp;nbsp; &amp;nbsp; Boolean &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.ValueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;So you are right and we can get rid of the -match operator!&lt;/p&gt;
&lt;p&gt;Klaus&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3466282" width="1" height="1"&gt;</description></item></channel></rss>