Skip to content

Instantly share code, notes, and snippets.

@notsle
Created December 29, 2023 01:43
Show Gist options
  • Save notsle/d3ab265d07957d459a32823e78e802a1 to your computer and use it in GitHub Desktop.
Save notsle/d3ab265d07957d459a32823e78e802a1 to your computer and use it in GitHub Desktop.
Get-DirHash.ps1
Function Get-DirHash {
[Cmdletbinding()]
Param(
[Parameter(Mandatory=$true)]
[ValidateScript({
if(Test-Path -Path $_ -ErrorAction SilentlyContinue)
{
return $true
}
else
{
throw "$($_) is not a valid path."
}
})]
[string]$Path
)
$temp = gci -File -Recurse $Path | Get-FileHash | select -ExpandProperty Hash | Out-String
$hash = Get-FileHash -InputStream ([IO.MemoryStream]::new([char[]]$temp))
$hash.Path=$Path
return $hash.Hash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment