title: Get-WmiObject from AD OU
body: <p>I have a simple problem that I can't seem to work through. I need to know what servers are still running server 2008/R2.</p>
  
  <p>I know that <code>Win32_OperatingSystem</code>'s <code>Name</code> property contains the information that I'm looking for. I would like to be able to run <code>Get-WmiObject</code> against a collection of servers in an OU. </p>
  
  <p>There are two problems that I'm having:</p>
  
  <ol>
  <li><p>I can't figure out how to redirect the output of <code>Get-ADComputer</code> to something that <code>Get-WmiObject -ComputerName</code> can use. I think <code>Get-ADComputer</code> is outputting objects of type <code>Microsoft.ActiveDirectory.Management.ADComputer</code>, and <code>Get-WmiObject</code> is looking for type <code>System.Management.ManagementObject</code>. Here's what I came up with but it doesn't appear to work.</p>
  
  <pre><code>Get-WmiObject Win32_OperatingSystem -ComputerName (Get-ADComputer -filter * -SearchBase "OU=Member Servers,DC=Company,DC=Com" | select @{L="ComputerName";e={$_."name"}}) -Property name, csname | select csname, name | Format-Table -AutoSize
  </code></pre></li>
  <li><p>My temp workaround: I was able to create a CSV that contains the list of server names. I was able to use the CSV to run <code>Get-WmiObject</code> against. However, the OU contains "dead" servers. So when I try to run <code>Get-WmiObject</code> using the CSV-list of servers that came from AD there are connection timeouts and PowerShell waits a period of time to see if the dead server will respond. This really slows down the operation &amp; we are working to clean this up. Until that happens, Is there a way to only pass the server names that pass a <code>Test-Connection</code> to <code>Get-WmiObject</code>?</p>
  
  <pre><code>Get-WmiObject win32_operatingsystem -ComputerName (Get-Content C:\Users\user1\Desktop\Servers.csv) -Property name, csname | select csname, name | Format-Table -AutoSize
  </code></pre></li>
  </ol>