Skip to content

Commit f46131a

Browse files
grigoryvpr15ch13
authored andcommitted
Fix PowerShell core crash due to '-Encoding byte' being replaced with '-AsByteStream' (#2554)
1 parent d56e8ae commit f46131a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/install.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,13 @@ function check_hash($file, $hash, $app_name) {
653653
$msg += "App: $app_name`n"
654654
$msg += "URL: $url`n"
655655
if(Test-Path $file) {
656-
$hexbytes = Get-Content $file -Encoding byte -TotalCount 8 | ForEach-Object { $_.tostring('x2') }
656+
if((Get-Command Get-Content).parameters.ContainsKey('AsByteStream')) {
657+
# PowerShell Core (6.0+) '-Encoding byte' is replaced by '-AsByteStream'
658+
$hexbytes = Get-Content $file -AsByteStream -TotalCount 8 | ForEach-Object { $_.tostring('x2') }
659+
}
660+
else {
661+
$hexbytes = Get-Content $file -Encoding byte -TotalCount 8 | ForEach-Object { $_.tostring('x2') }
662+
}
657663
$hexbytes = [string]::join(' ', $hexbytes).ToUpper()
658664
$msg += "First bytes: $hexbytes`n"
659665
}

0 commit comments

Comments
 (0)