title: Output debug information from pester test
body: <p>I'm writing a system in C# that has lots of features to test. One feature is a set of PowerShell custom cmdlets for managing my system.</p>
  <p>I'm using pester (v5) to test my cmdlets and will have a lot of test cases for the many scenarios that I want to test.</p>
  <p>I can use pester successfully but I can't get any debug output from the tests - only the test report. The test report is fine to see what's passing and failing but if I have a failure then I want to be able to output results that can give me the context of what is going wrong.</p>
  <p>I've tried all the settings I can think of for PesterConfiguration to no avail, e.g.</p>
  <pre><code>$PesterPreference = [PesterConfiguration]::Default
  #$PesterPreference.Output.Verbosity = &quot;Diagnostic&quot;
  $PesterPreference.Debug.WriteDebugMessages = $true
  #$PesterPreference.Debug.WriteDebugMessagesFrom = &quot;*&quot;
  </code></pre>
  <p>As an example, imagine I have a <code>get-foo</code> cmdlet that returns an object with a <code>Thing</code> property that should have a value of <code>&quot;Bar&quot;</code>.</p>
  <p>I can write a pester test to check this but I would like to be able to output the returned object as part of the test to see something like:</p>
  <pre><code>Name     Value
  ----     -----
  Thing    Bar
  Other    124
  </code></pre>
  <pre><code>Describe 'Test My CmdLet' {
    It 'get-foo should return bar' {
      $obj = get-foo   
      write-output $obj
      $obj | Should -Not -BeNullOrEmpty
      $obj.Thing | Should -Be &quot;Bar&quot;
    }
  }
  </code></pre>
  <p>Without the ability to get output then I have to reconstruct the test setup and structure outside of pester directly in PowerShell - which is a painful process.</p>
  <p>If anyone has any advice on how to get my output then I'd appreciate the advice.</p>
  <p>Thanks,</p>
  <p>David</p>