title: Powershell pitfalls
body: <p>What Powershell pitfalls you have fall into? :-) </p>
  
  <p>Mine are:</p>
  
  <pre><code># -----------------------------------
  function foo()
  {
      @("text")
  }
  
  # Expected 1, actually 4.
  (foo).length
  
  # -----------------------------------
  if(@($null, $null))
  {
      Write-Host "Expected to be here, and I am here."
  }
  
  if(@($null))
  {
      Write-Host "Expected to be here, BUT NEVER EVER."
  }
  
  # -----------------------------------
  
  function foo($a)
  {
      # I thought this is right.
      #if($a -eq $null)
      #{
      #    throw "You can't pass $null as argument."
      #}
  
      # But actually it should be:
      if($null -eq $a)
      {
          throw "You can't pass $null as argument."
      }
  }
  
  foo @($null, $null)
  
  # -----------------------------------
  
  # There is try/catch, but no callstack reported.
  function foo() 
  {
     bar
  }
  
  function bar() 
  {
    throw "test"
  }
  
  # Expected:
  #  At bar() line:XX
  #  At foo() line:XX
  #  
  # Actually some like this:
  #  At bar() line:XX
  foo
  </code></pre>
  
  <p>Would like to know yours to walk them around :-)</p>