Public/Get-pseBlobFileFromURL.ps1

function Get-pseBlobFileFromURL {
    <#
    .SYNOPSIS
    Downloads a file from the specified URL and saves it to the specified local path.
 
    .DESCRIPTION
    The Get-pseBlobFileFromURL function downloads a file from the given URL and saves it to the specified local file path. It utilizes Invoke-RestMethod to download the file.
 
    .PARAMETER FileUrl
    Specifies the URL of the file to be downloaded.
 
    .PARAMETER DestinationFilePath
    Specifies the local path where the downloaded file will be saved. Include the filename in the path.
 
    .EXAMPLE
    Get-pseBlobFileFromURL -FileUrl "https://example.com/file.zip" -DestinationFilePath "C:\Downloads\file.zip"
    Downloads the file from the specified URL and saves it to the specified local path.
 
    .NOTES
    Author: owen.heaume
    Change Log:
        - 1.0.0 Initial Release
    #>

    [cmdletbinding()]
    param (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
        [string]$FileUrl,
        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
        [string]$DestinationFilePath
    )

    begin {}

    process {
        foreach ($url in $FileUrl) {
            Try {
                # Download the file to $FileLocation
                Invoke-RestMethod -Uri $url -OutFile $DestinationFilePath -UseBasicParsing -ea stop -ev x | Out-Null
                Write-Host "File downloaded to $DestinationFilePath" -ForegroundColor DarkGray
            } Catch {
                [pscustomobject]@{
                    'FileUrl'      = $url.Split('?')[0]
                    'FilePath'     = $DestinationFilePath
                    'ErrorMessage' = $_.Exception.Message
                }
            }
        }
    }
}