Skip to content

Instantly share code, notes, and snippets.

@jessestricker
Created October 13, 2022 09:23
Show Gist options
  • Save jessestricker/304dacac4fb8af87d8a1dabf0eedb3d9 to your computer and use it in GitHub Desktop.
Save jessestricker/304dacac4fb8af87d8a1dabf0eedb3d9 to your computer and use it in GitHub Desktop.
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $Path,
[Parameter(Mandatory)]
[string] $Hash,
[ValidateSet("SHA1", "SHA256", "SHA512")]
[string] $Algorithm = "SHA256"
)
[string] $ActualHash = (Get-FileHash -Path $Path -Algorithm $Algorithm).Hash
Write-Debug "ActualHash = $ActualHash"
[bool] $Match = $ActualHash.Equals($Hash, [System.StringComparison]::InvariantCultureIgnoreCase)
Write-Debug "Match = $Match"
Write-Output $Match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment