Issue in downloading file from web url

Hi,

I made a script in which i am downloading a software from a url and made the whole environment for that in script but it is not running. Here is the script -

$url = “http://nuget.org/nuget.exe
$output = “$PSScriptRoot\nuget.exe”
$start_time = Get-Date
$downloadpath = “C:\Users\ankitpar\Downloads”
Invoke-WebRequest -Uri $url -OutFile $output Set-Location $downloadpath
Write-Output “Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)”

Error given on execution is -

Invoke-WebRequest :
A positional parameter cannot be found that accepts argument ‘Set-Location’.
At line:4 char:1

  • Invoke-WebRequest -Uri $url -OutFile $output Set-Location C:

$url = “http://nuget.org/nuget.exe
$start_time = Get-Date
$downloadpath = “C:\Users\Vincent\Downloads\Nuget.exe”
Invoke-WebRequest -Uri $url -OutFile $downloadpath
Write-Output “Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)”

If you want to save the file where script is located
$downloadpath = “$PSScriptRoot\nuget.exe”

thanks Vincent… its work…