Public/Get-SpecBlobFileFromURL.ps1

function Get-specBlobFileFromURL {
    <#
    .SYNOPSIS
    Downloads a file from the specified URL and saves it to the specified local path.
 
    .DESCRIPTION
    The Get-SpecBLOBFileFromURL 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-SpecBLOBFileFromURL -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:
        - 2.0.0 Uses invoke-restmethod
        - 2.0.1 Added error handling
                Accepts object as input or via pipeline
                Change parameter name for clarity
        - 2.0.2 Added alias for parameter
        - 2.0.1 Added error handling that can be used in try/catch blocks
    #>

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

    begin {}

    process {
        foreach ($url in $FileUrl) {
            Try {
                Write-Verbose "Downloading file from $url"
                Invoke-RestMethod -Uri $url -OutFile $DestinationFilePath -UseBasicParsing -ea stop -ev x
                Write-Verbose "File downloaded to $DestinationFilePath"
            } Catch {
                Write-Error "An error occurred downloading the file: $_"
            }
        }
    }
}