Module/Misc/Get-BCSWebFile.ps1

<#
.SYNOPSIS
    Download a file from a https or http URL
.DESCRIPTION
    Function downloads a file from the web and saves it on the local machine
     
.PARAMETER remoteURL
  URL to file to download
.PARAMETER destination
  Destination where the file will be saved
 
.NOTES
    Author: Mathias Stjernfelt
    Website: http://www.brightcom.se
 
.EXAMPLE
   Get-BCSWebFile -remoteURL "https://website.com/file.txt" -destination "c:\temp\file.txt"
#>

function Get-BCSWebFile {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")]
    Param(
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [String] $remoteURL,
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [SecureString] $destination
    )

    if ($remoteURL.StartsWith("https://", "OrdinalIgnoreCase") -or $remoteURL.StartsWith("http://", "OrdinalIgnoreCase")) {
        (New-Object System.Net.WebClient).DownloadFile($remoteURL, $destination)
        Write-Host "Downloaded file from $($remoteURL) to $($destination)"
    }
}
Export-ModuleMember -Function Get-BCSWebFile