~james/gengo

gengo/samples-test/samples/PowerShell/check_for_updates.ps1 -rw-r--r-- 895 bytes
50871857 — james chore(import): snapshot james.dad.town/gengo at 8f775550b0ee 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Define the current version of your program
$currentVersion = "1.0.0"

# Define the URL where version information is stored (replace with your actual URL)
$versionCheckUrl = "https://example.com/version.txt"

try {
    # Get the latest version from remote source
    $latestVersion = Invoke-WebRequest -Uri $versionCheckUrl -UseBasicParsing | Select-Object -ExpandProperty Content

    # Compare versions
    if ($latestVersion -gt $currentVersion) {
        Write-Host "Update available! Current version: $currentVersion, Latest version: $latestVersion"
        Write-Host "Please download the latest version from our website."
    }
    else {
        Write-Host "Your program is up to date. Version: $currentVersion"
    }
}
catch {
    Write-Host "Unable to check for updates. Please check your internet connection."
    Write-Host "Error: $($_.Exception.Message)"
}