title: What exactly is a PowerShell ScriptBlock
body: <p>A PowerShell ScriptBlock is not a <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29">lexical closure</a> as it does not close over the variables referenced in its declaring environment. Instead it seems to leverage dynamic scope and free variables which are bound at run time in a lambda expression.</p>
  
  <pre><code>function Get-Block {
    $b = "PowerShell"
    $value = {"Hello $b"}
    return $value
  }
  $block = Get-Block
  &amp; $block
  # Hello
  # PowerShell is not written as it is not defined in the scope
  # in which the block was executed.
  
  
  function foo {
    $value = 5
    function bar {
      return $value
    }
    return bar
  }
  foo
  # 5
  # 5 is written $value existed during the evaluation of the bar function
  # it is my understanding that a function is a named scriptblock
  #  which is also registered to function:
  </code></pre>
  
  <p>Calling GetNewClosure() on a ScriptBlock returns a new ScriptBlock which closes over the variables referenced. But this is very limited in scope and ability.</p>
  
  <p>What is a ScriptBlock's classification?</p>