diff --git a/tasks/agent_install.ps1 b/tasks/agent_install.ps1
index fcc8456e..33e00c1a 100644
--- a/tasks/agent_install.ps1
+++ b/tasks/agent_install.ps1
@@ -8,8 +8,9 @@ if (Test-Path "C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet"){
   Exit 1
 }
 $flags=$install_flags -replace '^\["*','' -replace 's/"*\]$','' -replace '/", *"',' '
+$mypath = $MyInvocation.MyCommand.Path | Split-Path -Parent
 try {
-  [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $webClient = New-Object System.Net.WebClient; $webClient.DownloadFile("https://${server}:8140/packages/current/install.ps1", 'install.ps1'); powershell.exe -c "install.ps1 $flags"
+  [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $webClient = New-Object System.Net.WebClient; $webClient.DownloadFile("https://${server}:8140/packages/current/install.ps1", "${mypath}\install.ps1"); powershell.exe -c "${mypath}\install.ps1 $flags"
   }
   catch {
   Write-Host "Installer failed with Exception: $_.Exception.Message"