top of page

Script to Get Hash Value of a Directory

Vadims Podans has posted a script for PowerShell here which can be used to generate the hash value of a folder containing multiple files.

Simply copy and paste this function in PowerShell:

function Get-FolderHash ($folder) { dir $folder -Recurse | ?{!$_.psiscontainer} | %{[Byte[]]$contents += [System.IO.File]::ReadAllBytes($_.fullname)} $hasher = [System.Security.Cryptography.SHA1]::Create() [string]::Join("",$($hasher.ComputeHash($contents) | %{"{0:x2}" -f $_})) }

Then enter the command:

Get-FolderHash "C:\foofolder"

A single SHA1 hash value will be generated for the entire folder.

The views expressed in these posts are those of the owner and do not reflect the views or opinions of the owner’s employer. All content provided on this page is for informational purposes only. The owner makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information. This policy is subject to change at any time. The owner is not an attorney, and nothing posted on this site should be construed as legal advice. Litigation Support Tip of the Night does not provide confirmation that any e-discovery technique or conduct is compliant with legal, regulatory, contractual or ethical requirements.

bottom of page