Skip to content

Instantly share code, notes, and snippets.

@motowilliams
Created March 1, 2016 23:04
Show Gist options
  • Select an option

  • Save motowilliams/85026fd67b79780e10de to your computer and use it in GitHub Desktop.

Select an option

Save motowilliams/85026fd67b79780e10de to your computer and use it in GitHub Desktop.
Simple MD5 checksum to see if the local file hash matches the declared remote md5 checksum
$url = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$output = "$PSScriptRoot\nuget.exe"
$headRequest = Invoke-WebRequest -Method head -Uri $url
$remotehash = $headRequest.Headers.'Content-MD5'
Invoke-WebRequest -Uri $url -OutFile $output
$fileData = Get-FileHash -Path $output -Algorithm MD5
$bytes = [System.Text.Encoding]::UTF8.GetBytes($fileData.Hash)
$localhash = [System.Convert]::ToBase64String($bytes)
$remotehash
$localhash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment