function Get-PackageForInstallation { <# .SYNOPSIS Downloads a File to the Specified Outputfolder #> [CmdletBinding()] Param( [Parameter(Mandatory = $true)] [string]$loglead, [Parameter(Mandatory = $true)] [string]$outputFolder, [Parameter(Mandatory = $true)] [string]$outputfileName, [Parameter(Mandatory = $true)] [string]$downloadUrl ) if (!(Test-Path $outputFolder)) { Write-Verbose ("$logLead : Creating Package Download Folder {0}" -f $outputFolder) New-Item $outputFolder -ItemType Directory | Out-Null } $downloadFile = (Join-Path $outputFolder $outputfileName) if (Test-Path $downloadFile) { # If a job is rerun, this should prevent downloading again, unless it spans a day Write-Host ("$logLead : Using Existing Package from {0}" -f $downloadFile) } else { Write-Host ("$logLead : Downloading File from {0} to {1}" -f $downloadUrl, $downloadFile) Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadFile } return $downloadFile }