Skip to content

Instantly share code, notes, and snippets.

@andrewodri
Created March 18, 2021 13:52
Show Gist options
  • Save andrewodri/04b63bd6d49e59c2007a1508d39c4fa7 to your computer and use it in GitHub Desktop.
Save andrewodri/04b63bd6d49e59c2007a1508d39c4fa7 to your computer and use it in GitHub Desktop.
Download, validate and expand archive using PowerShell
$ArchiveHash = '2c1ab54ac560327ed45fdc28a106d539'
New-Item -ItemType Directory -Path '/tmp'
(New-Object System.Net.WebClient).DownloadFile('https://example.com/archive.zip', '/tmp/archive.zip');
if ( ( Get-FileHash -Path '/tmp/archive.zip' -Algorithm MD5 ).Hash -eq $ArchiveHash ) { Write-Output 'Could not validate hash.' } else { exit }
Expand-Archive -Path '/tmp/archive.zip' -DestinationPath '/tmp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment