title: PowerShell 3 Parameters
body: <p>Hi Basically i'm having an issue i need to load Arguments in to the following code  located at the <code>$URL</code> &amp; <code>$Output</code> but i need it to work with the <code>Join-Path</code> but every time i try it kicks back a load of errors i'm new to this so i am trying everything to get it working I've been asked to do this by my boss completely out my depth but never been one to shy away from a challenge</p>
  
  <pre class="lang-psh prettyprint-override"><code>Function DownloadFileFromURL
  {
  Add-Type -AssemblyName Microsoft.Visualbasic
  #$url = 'http://download.microsoft.com/download/F/4/2/F42AB12D-C935-4E65-9D98-4E56F9ACBC8E/wpilauncher.exe'
  $url = $args[0]
  $filename = Split-Path -leaf $url
  $output = Join-Path $args1 + $filename
  $response = [System.Net.WebRequest]::Create($url).GetResponse()
  $realurl = $response.ResponseUri.OriginalString
  $response.Close()
  (New-Object Net.WebClient).DownloadFile($url, $output)
  
  
  #################Time Taken To Download Files###################### 
  $start_time = Get-Date
  Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
  
  }
  
      DownloadFileFromURL ('http://download.microsoft.com/download/F/4/2/F42AB12D-C935-4E65-9D98-4E56F9ACBC8E/wpilauncher.exe','C:\Users\Martin.beardmore\Downloads\test')
  </code></pre>
  
  <p>Errors being Recieved</p>
  
  <pre><code>Join-Path : Cannot bind argument to parameter 'Path' because it is null.
  At C:\Users\Martin.beardmore\Documents\Query download.ps1:6 char:21
  + $output = Join-Path $args[1] + $filename
  +                     ~~~~~~~~
      + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
  
  Cannot convert argument "requestUri", with value: "System.Object[]", for "Create" to type "System.Uri": "Cannot convert the "System.Object[]" value of type "System.Object[]" to type 
  "System.Uri"."
  At C:\Users\Martin.beardmore\Documents\Query download.ps1:7 char:1
  + $response = [System.Net.WebRequest]::Create($url).GetResponse()
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodException
      + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
  
  You cannot call a method on a null-valued expression.
  At C:\Users\Martin.beardmore\Documents\Query download.ps1:9 char:1
  + $response.Close()
  + ~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  
  Cannot convert argument "address", with value: "System.Object[]", for "DownloadFile" to type "System.Uri": "Cannot convert the "System.Object[]" value of type "System.Object[]" to type 
  "System.Uri"."
  At C:\Users\Martin.beardmore\Documents\Query download.ps1:10 char:1
  + (New-Object Net.WebClient).DownloadFile($url, $output)
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodException
      + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
  </code></pre>