title: How to set the default ToString() on a locally created PSObject?
body: <p>I'd like to be able to set the default text rendering of a PSObject I create. For example, I'd like this code:</p>
  
  <pre><code>new-object psobject -property @{ name = 'bob'; job = 'janitor' }
  </code></pre>
  
  <p>which currently outputs this:</p>
  
  <pre><code>name  job
  ----  ---
  bob   janitor
  </code></pre>
  
  <p>to instead output this:</p>
  
  <pre><code>name  job
  ----  ---
  bob   he is a janitor, he is
  </code></pre>
  
  <p>I.e. attach script block to the PSObject's ToString() that just does this:</p>
  
  <pre><code>{ 'he is a {0}, he is' -f $job }
  </code></pre>
  
  <p>I don't need to do an <code>add-type</code> with some C# for the type, do I? I hope not. I make lots of local psobjects and would like to scatter to-strings on them to help make their output nicer, but if it's a lot of code it probably won't be worth it.</p>