ps/Modules/Alkami.DevOps.Common/Public/Get-PackageForInstallation.ps1
2023-05-30 22:51:22 -07:00

40 lines
1.1 KiB
PowerShell

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
}