Skip to content

Instantly share code, notes, and snippets.

@vexx32
Created September 20, 2021 19:09
Show Gist options
  • Save vexx32/74bcbde8991a4bd27245313ebee4c406 to your computer and use it in GitHub Desktop.
Save vexx32/74bcbde8991a4bd27245313ebee4c406 to your computer and use it in GitHub Desktop.
checksum comparison for files vs a given checksum file
function Test-Checksum {
[CmdletBinding()]
[Alias('checksum')]
param(
[Parameter(Mandatory, Position = 0)]
[string]
$Path,
[Parameter(Mandatory, Position = 1)]
[string]
$ChecksumPath
)
$reportedHash = Get-Content -Path $ChecksumPath
$actualHash = Get-FileHash -Path $Path
$actualHash.Hash -eq $reportedHash.Trim()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment