title: accessing the $args array in powershell
body: <p>I have a test powershell V2 script that looks like this:</p>
  
  <pre><code>    function test_args()
      {
        Write-Host "here's arg 0: $args[0]"
        Write-Host "here's arg 1: $args[1]"
      }
  
  
      test_args
  </code></pre>
  
  <p>If I call this from the powershell command prompt I get this on the screen:</p>
  
  <pre><code>here's arg[0]: [0]
  
  here's arg[1]: [1]
  </code></pre>
  
  <p>Not quite what I wanted.  It seems I have to copy $args[0] and $args[1] to new variables in the script before I can use them?  If I do that I can access things fine.</p>
  
  <p>Is there a way to access the indexed $args in my code?  I've tried using curly braces around them in various ways but no luck.  </p>
  
  <p>I'll be moving to named parameters eventually, but the script I'm working on (not this demo one) is a straight port of a batch file.</p>