Skip to content

Instantly share code, notes, and snippets.

@MaxAnderson95
Last active September 25, 2019 00:35
Show Gist options
  • Save MaxAnderson95/ee9a9156d7f16624850177798a720b1e to your computer and use it in GitHub Desktop.
Save MaxAnderson95/ee9a9156d7f16624850177798a720b1e to your computer and use it in GitHub Desktop.
Hashes a directory of files and generates a single SHA1 hash
Function Get-FolderHash ($Folder) {
Get-ChildItem $folder -Recurse -Exclude "*.psd1" | Where-Object {!$_.psiscontainer} | ForEach-Object {[Byte[]]$contents += [System.IO.File]::ReadAllBytes($_.fullname)}
$hasher = [System.Security.Cryptography.SHA1]::Create()
[string]::Join("",$($hasher.ComputeHash($contents) | %{"{0:x2}" -f $_}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment