Functions/Private/Get-FileFromUrl.ps1

function Get-FileFromUrl {
    [CmdletBinding()]
    param ([string] $ToolPath
        , [string] $url
        )
    Process {
        New-ToolPath $ToolPath
        
        $HttpMetadata = Get-UrlMetadata -url $url;

        #Meta data file to store information about the download for future comparisons
        $MetaDataFilePath = Get-MetadataFile  $ToolPath

        if (Test-ShouldDownload -MetaDataFilePath $MetaDataFilePath -HttpResponse $HttpMetadata) {
            $toolFile = join-path $ToolPath $HttpMetadata.Filename 
            Write-Verbose "Downloading file $toolFile"
            Invoke-WebRequest  $url -OutFile $toolFile
            Write-Output @{MetaData=$HttpMetadata;Filename=$toolFile}
        }
    }
    
}