Created
March 1, 2016 23:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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