-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupUtil.psm1
29 lines (26 loc) · 1.13 KB
/
setupUtil.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function VerifyFileContentByHashsum ($local_file, $SHA256) {
if (-Not (Test-Path $local_file)) {
Write-Host -ForegroundColor Red "$local_file MISSING"
exit -2
}
if ((Get-FileHash $local_file).Hash -eq $SHA256) {
Write-Host -ForegroundColor Green "Found $local_file"
} else {
Write-Host -ForegroundColor Red "$local_file UNEXPECTED HASH $((Get-FileHash $local_file).Hash)"
exit -2
}
}
function VerifyOrDownload ($local_file, $URL, $SHA256) {
if (-Not (Test-Path $local_file)) {
Write-Host -ForegroundColor Green " Downloading $URL"
Write-Host -ForegroundColor Green " To $local_file"
# $progresspreference = 'silentlyContinue' # Speedup Invoke-WebRequest
# Invoke-WebRequest -Uri $URL -OutFile $local_file
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
(New-Object System.Net.WebClient).DownloadFile($URL, $local_file)
}
VerifyFileContentByHashsum $local_file $SHA256
}
function ProductcodeExists($productCode) {
Test-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$productCode
}