title: Accessing values of object properties in PowerShell
body: <p>I'm going through an array of objects and I can display the objects fine.</p>
  
  <pre><code>$obj
  </code></pre>
  
  <p>displays each object in my foreach loop fine.
  I'm trying to access the object fields and their values.
  This  code also works fine:</p>
  
  <pre><code>$obj.psobject.properties
  </code></pre>
  
  <p>To just see the names of each object's fields, I do this:</p>
  
  <pre><code>$obj.psobject.properties | % {$_.name}
  </code></pre>
  
  <p>which also works fine.</p>
  
  <p>When I try to access the values of those field by doing this:</p>
  
  <pre><code>$obj.psobject.properties | % {$obj.$_.name}
  </code></pre>
  
  <p>nothing is returned or displayed. </p>
  
  <p>This is done for diagnostic purposes to see whether I can access the values of the fields.
  The main dilemma is that I cannot access a specific field's value. I.e. </p>
  
  <pre><code>$obj."some field"
  </code></pre>
  
  <p>does not return a value even though I have confirmed that "some field" has a value.</p>
  
  <p>This has baffled me. Does anyone know what I'm doing wrong?</p>