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 FilePath
    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" -FilePath "C:\Downloads\file.zip"
    Downloads the file from the specified URL and saves it to the specified local path.
 
    .NOTES
    Author: owen.heaume
    Version 2.0 - Uses invoke-restmethod
    #>

    [cmdletbinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$FileUrl,
        [Parameter(Mandatory = $true)]
        [string]$FilePath
    )

    Try {
        # Download the file to $FileLocation
        Invoke-RestMethod -Uri $FileUrl -OutFile $FilePath -UseBasicParsing -ea stop -ev x
        return 0
        Write-Verbose "Completed file download"
    } Catch {
        $ErrorMessage = $_.Exception.Message
        #Write-Error "Error $ErrorMessage downloading file from [$FileUrl] $x"
        return 1
    }
}