Public/Get-RemoteChecksum.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Author: Miodrag Milic <miodrag.milic@gmail.com>
# Last Change: 26-Nov-2016.

<#
.SYNOPSIS
    Download file from internet and calculate its checksum
 
#>

function Get-RemoteChecksum( [string] $Url, $Algorithm='sha256' ) {
    $fn = [System.IO.Path]::GetTempFileName()
    Invoke-WebRequest $Url -OutFile $fn -UseBasicParsing
    $res = Get-FileHash $fn -Algorithm $Algorithm | % Hash
    rm $fn -ea ignore
    return $res.ToLower()
}