title: Could someone explain this bizarre PSObject + add-member behavior for Powershell?
body: <p>I just don't understand why this is happening. If I create two separate new PSObjects, they seem to affect each other. For example, with this code:</p>
  
  <pre><code>$o1 = new-object psobject
  $o1 | add-member noteproperty abc 123
  
  $o2 = new-object psobject
  $o2 | add-member noteproperty def 456
  
  write-output $o1
  write-output $o2
  </code></pre>
  
  <p>I would expect to see output for both abc and def, yet I only get abc:</p>
  
  <pre><code>abc
  ---
  123
  </code></pre>
  
  <p>If I use write-host instead, like this:</p>
  
  <pre><code>write-host $o1
  write-host $o2
  </code></pre>
  
  <p>Then it shows output like this:</p>
  
  <pre><code>@{abc=123}
  @{def=456}
  </code></pre>
  
  <p>So according to write-output, $o2 is null/empty, but write-host says that's a lie.</p>
  
  <p>What's going on?</p>