Use -Path instead of -InputStream parameter for Get-FileHash (closes #1905)

Fixes a problem with Get-FileHash not excepting -InputStream parameter in PowerShell 4.0
This commit is contained in:
Richard Kuhnt
2017-12-12 21:39:52 +01:00
parent da7d61f3e3
commit da9c8e228a
+2 -2
View File
@@ -452,10 +452,10 @@ function check_hash($file, $url, $manifest, $arch) {
function compute_hash($file, $algname) {
try {
$fs = [system.io.file]::openread($file)
if([bool](Get-Command -Name Get-FileHash -ErrorAction SilentlyContinue) -eq $true) {
return (Get-FileHash -InputStream $fs -Algorithm $algname).Hash.ToLower()
return (Get-FileHash -Path $file -Algorithm $algname).Hash.ToLower()
} else {
$fs = [system.io.file]::openread($file)
$alg = [system.security.cryptography.hashalgorithm]::create($algname)
$hexbytes = $alg.computehash($fs) | % { $_.tostring('x2') }
return [string]::join('', $hexbytes)