From 9bd42bbfade7a27b7429b0900a7aebc0683a8a08 Mon Sep 17 00:00:00 2001 From: chausner Date: Tue, 30 Jun 2020 18:39:39 +0200 Subject: [PATCH] Use an in-memory stream in YamlCreate.ps1 for hash computation (#478) Co-authored-by: Kevin Larkin (MS) --- Tools/YamlCreate.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tools/YamlCreate.ps1 b/Tools/YamlCreate.ps1 index ff3e9067e..0b744891c 100644 --- a/Tools/YamlCreate.ps1 +++ b/Tools/YamlCreate.ps1 @@ -5,9 +5,6 @@ # define variables $OFS = "`r`n" #linebreak -$tempFolder=$env:TEMP; -# Create a temporary file to generate a sha256 value. -$Hashfile=$tempFolder + "\TempfileName.txt" # Prompt for URL While ($url.Length -eq 0) { @@ -17,16 +14,19 @@ $OFS write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue $WebClient = New-Object System.Net.WebClient # This downloads the installer + try { - $WebClient.DownloadFile($URL, $Hashfile) + $stream = $WebClient.OpenRead($URL) } catch { write-host "Error downloading file. Please run the script again." -ForeGroundColor red exit 1 } + # This command will get the sha256 hash -$Hash=get-filehash $hashfile +$Hash=get-filehash -InputStream $stream +$stream.Close() $string = "Url: " + $URL ;