title: Powershell: How to reference the columns in a select
body: <p>I'm using PowerShell 5.1 to iterate through a list of computers from active directory, and I'm struggling with something that should be simple.</p>
  <p>In the code below, I'm selecting the name and description for each computer in a foreach loop. How should I reference the name and description individually inside the loop?</p>
  <pre><code>    $OU=@('OU=...') 
      $computers = $OU | foreach {Get-ADComputer -filter {
      Name -notlike 'xxx*' 
      -and Name -notlike 'yyy*' 
      } -searchbase $_  -Properties description | Select name, description }
   
      foreach ($computer in $computers) {
        $computerName = $computer | select -ExpandProperty name
        $computerDescription =  $computer | select -ExpandProperty description
        Write-Host &quot;Host: $computerName [$computerDescription]&quot;
      }
  </code></pre>
  <p>I was able to  get it to work using <code>select -ExpandProperty</code> , but this seems unnecessarily complicated. The $computer variable holds key/value pairs like this:</p>
  <pre><code>@{name=ABCDE12345; description=Kiosk PC [Domain Separated]}
  </code></pre>
  <p>I tried using dot notation <code>$computer.name $computer.description</code> but the dot was ignored and treated as text.</p>
  <p>I have tried googling this, but I'm new to PowerShell and not sure how to phrase my question!</p>