Windows Powershell Script for Comparing Hash Values
- Edit the PowerShell file named 'get-hash.ps1': you'll be editing two different variable's values.
- For the variable named
$file
: Update its value with the name & path to the file you want to compare hash values for. (eg. C:\example-directory-name\file-name.exe) - For the variable named
$providedHash
: Update its value with the hash value provided by the vendor or download source. (eg. Will be a long alphanumeric string) - Save the changes to your file.
- Open up a terminal window in Windows PowerShell
- Within your PowerShell terminal window you will run the script by referencing its file name. Type
'get-hash.ps1'
- Hit 'Enter' - This will run the script to compare the hash values.
- If the hash values match you will get a success message. If they do not match you will get a message that informs the values do NOT match.
I've got a ton of other repos, but this is actually my 1st public MIT licensed repository.
I created this repository and script because I didn't know much about hashes, checksums and all of that. I was trying to download an executable file from the web and wanted to compare the hash values.
I did several web searches for tools to do this, but had that feeling cause I didn't actually know any of the publishers for those GUI based apps.
Also, using the GUI tool would mean I wouldn't really know much more about the process than when I went into this.
I appreciate when I can do something myself cause the process always leaves me better educated than when I went into it.
So I set out and began learning about the topic in a deeper way.
Sometime later I had gotten to the point to write my first script.
I learned some PowerShell scripting along the way too - which was cool. Cause this is also my very first PowerShell script ever; which is a dope feelin' for me.
Anyway, I hope this script is helpful to someone else down the line. If you're liking it def let me know.
In time I hope to make it more robust and sophisticated as I've got time and the desire to. But, for now it's serving the purpose that originally moved me to do this in the first place.
If you're not familiar with setting your execution policy peep some info here setting execution policy | MSDN Microsoft: https://msdn.microsoft.com/powershell/reference/5.1/Microsoft.PowerShell.Core/about/about_Execution_Policies to help you get up and running.
I've added an additional PowerShell script with example scripts for setting execution policy to help get ya started.
Links that helped me along the way. This list is reverse chronological order from how I found 'em. If you're new to this as I am/was, start at the bottom then work your way towards to top of the list:
- Choosing a git repo license Choose an open source license
- Multiple Write-Host to add new lines Don't do that #3 by Steve Renard
- PowerShell tip of the week TechNet
- Get-FileHash msdn Microsoft by JuanPablo Jofre
- Hexidecimal Wikipedia on Hexidecimal or Base 16
- Are SHA values case sensitive | DuckDuckGo search result
- JosepMV Get-Hash GitHub repository
- Get-Hash a PowerShell hash function by Josep
- How to automate file hash check with PowerShell by Adam Bertram
- Comparing Hash of downloaded files with PowerShell by Shawn Cicoria
- Compare FileHash in PowerShell | StackOverflow
- Compare Filehash in PowerShell | DuckDuckGo search result
- Easily Unblock All Files in a Directory Using PowerShell by The Scripting Guys | Before you can run a PowerShell script you've gotta unblock and enable the functionality. This post will explain how to do that.
- Unblock a file with PowerShell cmdlet | DuckDuckGo search result
- Signing your scripts by JuanPablo Jofre
- About PowerShell Execution Policies by JuanPablo Jofre
- Windows PowerShell, Securing the Shell by Don Jones
- Setting ExecutionPolicy by JuanPablo Jofre
- How to use the PowerShell 1.0: A Beginners Guide.
- Gurnec HashCheck | gitHub repo
- Get-FileHash by JuanPablo Jofre, info about the cmdlet
- How to get an MD5 checksum in PowerShell | StackOverflow
- Is there a built-in checksum utility on Windows 7? | SuperUser on StackExchange
- Linux command line cheat sheet
Peace y'all. Reuben