Last active
July 1, 2022 18:08
-
-
Save cisterni/23e2d69079ff1f2ebef1c31dc7cf974a to your computer and use it in GitHub Desktop.
Compute file hash and generate script check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-HashCheck { | |
[CmdletBinding()] | |
Param([Parameter(ValueFromPipeline)]$o) | |
process { | |
Write-Output "File: $([System.IO.FileInfo]::new($o.Path).Name)"; Write-Output '' | |
Write-Output ($o | select Algorithm, Hash) | |
Write-Output '' | |
Write-Output ('Get-FileHash -Algorithm SHA256 .\' + ([System.IO.FileInfo]::new($o.Path).Name) + ' |% { if ($_.Hash -eq "' + ($o.Hash) + '") { Write-Output "Test $([System.IO.FileInfo]::new($_.Path).Name) OK" } else { Write-Output "Test $([System.IO.FileInfo]::new($_.Path).Name) KO" }}') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage example
Get-FileHash -Algorithm SHA256 myfile.zip | Get-HashCheck