Member-only story

Generate file hash for specific files on your computer on a large scale

George Seah
3 min readFeb 22, 2021

--

After a long discussion, I was tasked by my boss to find out any open source program that can perform this activity.

With powershell, it is easy. A simple google search plus a few modifications allowed me to come up with this line. You may copy and paste this into a notepad then rename to GetHash.ps1.

Get-ChildItem -Path C:\Windows\Temp -Force -Recurse -Include “*.exe”,”*.dll”,”*.dat” -ErrorAction SilentlyContinue | Get-FileHash -Algorithm MD5 | Export-CSV D:/${env:COMPUTERNAME}_$(get-date -f yyyyMMdd).csv

This allowed me to perform the following:

  1. Hash all exe, dll and dat files in recursively within C:\Windows\Temp
  2. Export to a CSV file to D:/ with my computer name and the date upon execution of this script.
  3. Ability to change the hashing algorithm to MD5 or SHA1 or SHA256

This is perfect if powershell is enabled on your environment. However, this is not the same with my case. I had to use an external program to fulfil this one-time file hash generation requirement.

With reference from https://www.nirsoft.net/utils/hash_my_files.html, I managed to create a bat file to run the exe with the following parameters:

@echo off
“%~dp0HashMyFiles.exe” /MD5 1 /SHA1 0 /SHA256 0 /CRC32 0 /SHA512 0 /SHA384 0 /wildcard “C:\Windows\Temp\*.dat” 1000 /stab “D:/%COMPUTERNAME%_%DATE%_dat.csv” /SaveDirect

--

--

No responses yet