From ffd91c0c1d071378d383ad94ba915e2c10dff06b Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 17 Oct 2017 13:58:36 -0700 Subject: [fetchDependency] Call Get-FileHash if available, otherwise fallback --- scripts/fetchDependency.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index d2e2b89fd..e8c66c84d 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -194,17 +194,17 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion #calculating the hash - if ($PSVersionTable.PSEdition -ne "Core") + if (Test-Command -commandName 'Get-FileHash') + { + $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash + } + else { $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256") $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath) $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) $downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_}) } - else - { - $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash - } if ($expectedDownloadedFileHash -ne $downloadedFileHash) { -- cgit v1.2.3