title: Pass a function (with arguments) as a parameter in PowerShell
body: <p>I've been successfully passing no-argument functions around in PowerShell using ScriptBlocks. However, I can't get this to work if the function has arguments. Is there a way to do this in PowerShell? (v2 preferably)</p>
  
  <pre><code>Function Add([int] $x, [int] $y)  
  { 
    return $x + $y 
  }
  Function Apply([scriptblock] $s)    
  { 
      write-host ($s.Invoke(1,2)) 
  }
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>Apply { Add } 
  </code></pre>
  
  <p>writes 0 to the console. Apply does invoke <code>Add</code>, but doesn't pass any arguments in (i.e. uses the default [int] values of 0 and 0)</p>