forked from MultiPoolMiner/MultiPoolMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdater.ps1
47 lines (38 loc) · 1.95 KB
/
Updater.ps1
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using module .\Include.psm1
param([String]$MPMVersion, [String]$PSVersion, [String]$NFVersion)
if ($script:MyInvocation.MyCommand.Path) {Set-Location (Split-Path $script:MyInvocation.MyCommand.Path)}
$ProgressPreferenceBackup = $ProgressPreference
$Name = "MultiPoolMiner"
try {
$ProgressPreference = "SilentlyContinue"
$Request = Invoke-RestMethod -Uri "https://api.github.com/repos/multipoolminer/$Name/releases/latest" -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop
$Version = ($Request.tag_name -replace '^v')
$Uri = $Request.assets | Where-Object Name -EQ "$($Name)V$($Version).zip" | Select-Object -ExpandProperty browser_download_url
if ($Version -ne $MPMVersion) {
$ProgressPreference = $ProgressPreferenceBackup
Write-Progress -Activity "Updater" -Status $Name -CurrentOperation "Acquiring Online ($URI)"
$ProgressPreference = "SilentlyContinue"
Write-Log -Level Warn "The software ($Name) is out of date; there is an updated version available at $URI. "
}
}
catch {
Write-Log -Level Warn "The software ($Name) failed to update. "
}
$Name = "PowerShell"
try {
$ProgressPreference = "SilentlyContinue"
$Request = Invoke-RestMethod -Uri "https://api.github.com/repos/powershell/$Name/releases/latest" -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop
$Version = ($Request.tag_name -replace '^v')
$URI = $Request.assets | Where-Object Name -EQ "$($Name)-$($Version)-win-x64.msi" | Select-Object -ExpandProperty browser_download_url
if ($Version -ne $PSVersion) {
$ProgressPreference = $ProgressPreferenceBackup
Write-Progress -Activity "Updater" -Status $Name -CurrentOperation "Acquiring Online ($URI)"
$ProgressPreference = "SilentlyContinue"
Expand-WebRequest $URI -ErrorAction Stop
}
}
catch {
Write-Log -Level Warn "The software ($Name) failed to update. "
}
$ProgressPreference = $ProgressPreferenceBackup
Write-Progress -Activity "Updater" -Completed