title: Powershell equivalent of LINQ's Select command?
body: <p>I am trying to run the following Powershell script.</p>
  
  <pre><code>import-module ActiveDirectory
  
  $computers = Get-ADComputer -filter * -SearchBase "OU=myOU,DC=vw,DC=local" | select-object name
  
  Invoke-Command -ComputerName $computers -ScriptBlock {gpupdate /target:Computer}
  </code></pre>
  
  <p>The issue is <code>$computers</code> is not a <code>string[]</code> like <code>-ComputerName</code> expects. It really is a Array of <code>ADComputer</code> with one paramter called name.</p>
  
  <pre><code># Get-ADComputer -filter * -SearchBase "OU=myOU,DC=vw,DC=local" | select-object name | Format-Custom
  
  class ADComputer
  {
    name = PC1
  }
  
  class ADComputer
  {
    name = PC2
  }
  
  class ADComputer
  {
    name = PC3
  }
  </code></pre>
  
  <p>What is the correct way to get a array of strings for the names? If I was in C# I know it would be </p>
  
  <pre><code>string[] computerNames = computers.Select(computer =&gt; computer.name).ToArray();
  </code></pre>
  
  <p>but I want to learn how to do it in Powershell correctly.</p>