title: How to expand a PowerShell array when passing it to a function
body: <p>I have two PowerShell functions, the first of which invokes the second. They both take N arguments, and one of them is defined to simply add a flag and invoke the other. Here are example definitions:</p>
  
  <pre><code>function inner
  {
    foreach( $arg in $args )
      {
        # do some stuff
      }
  }
  
  function outer
  {
    inner --flag $args
  }
  </code></pre>
  
  <p>Usage would look something like this:</p>
  
  <pre><code>inner foo bar baz
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>outer wibble wobble wubble
  </code></pre>
  
  <p>The goal is for the latter example to be equivalent to</p>
  
  <pre><code>inner --flag wibble wobble wubble
  </code></pre>
  
  <p><strong>The Problem:</strong> As defined here, the latter actually results in two arguments being passed to <code>inner</code>: the first is "--flag", and the second is an array containing "wibble", "wobble", and "wubble". What I want is for <code>inner</code> to receive four arguments: the flag and the three original arguments.</p>
  
  <p>So what I'm wondering is how to convince powershell to expand the $args array before passing it to <code>inner</code>, passing it as N elements rather than a single array. I believe you can do this in Ruby with the splatting operator (the * character), and I'm pretty sure PowerShell can do it, but I don't recall how.</p>