title: How does the Count property work in Powershell?
body: <p>I've made a most unfortunate typo costing me quite some precious time:</p>
  
  <pre><code>$errors.Count
  </code></pre>
  
  <p>This returns "<code>0</code>", even if there are errors, because the variable name should be <em>singular</em>. This <em>does</em> work:</p>
  
  <pre><code>$error.clear()                # To ensure a correct repro
  Copy-Item asdf fdsa           # Will show an error
  $error.Count                  # Will output "1"
  </code></pre>
  
  <p>However, I now want to know why <code>$errors.Count</code> gave me <em>anything at all</em>, and why it gave me "<code>0</code>". So I went on to do some testing, and got the following results:</p>
  
  <pre><code>$asdf.Count                   # Will output "0"
  $nrOfEinsteinsInSpace.Count   # Will output "0"
  $a = 0; $a.Count;             # Will output "1"
  $b = 2; $a.Count;             # Will output "1"
  $x = 1,2,3; $x.Count;         # Will output "3"
  </code></pre>
  
  <p>And gathering even more data to be able to ask a sensible question here I did:</p>
  
  <pre><code>$true.Count                   # Will output "1"
  $false.Count                  # Will output "1"
  </code></pre>
  
  <p>So we have the following different cases:</p>
  
  <ol>
  <li>Array(like) variables, where <code>.Count</code> will output the number of items.</li>
  <li>Non-existent variables, where <code>.Count</code> will output "0".</li>
  <li>Declared variables, where <code>.Count</code> will output "1".</li>
  <li>Built-in variables, where <code>.Count</code> will output "1".</li>
  </ol>
  
  <p>Case 2, 3, and 4 don't make any sense to me (yet). What is going on here? Where is this documented? How does the <code>.Count</code> property work?</p>