ps-scripts/Windows/FirefoxAutoUpdate.ps1

29 lines
1.2 KiB
PowerShell
Raw Normal View History

# On verifie quelle version est installée
if (Test-Path "C:\Program Files\Mozilla Firefox\firefox.exe") {
$installedVersion = (Get-ItemProperty "HKLM:\Software\Mozilla\Mozilla Firefox" -Name "CurrentVersion").CurrentVersion
Write-Host "Version installee: $installedVersion"
} else {
Write-Host "Firefox n'est pas installe."
}
# On récupère la dernière version
$r = Invoke-WebRequest -Uri "https://www.mozilla.org/fr-FR/firefox/new/"
$latestVersion = $r.Content.Split([Environment]::NewLine) | Select-String 'data-latest-firefox' |
ForEach-Object { $_.ToString().Split('"')[9] }
# On fait le comparo entre la version installée et la dernière disponible
if ($installedVersion -lt $latestVersion) {
Write-Host "Nouvelle version disponible: $latestVersion"
# On DL la nouvelle version
$url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=fr-FR"
$output = "C:\Users\$env:USERNAME\Downloads\FirefoxSetup.exe"
Invoke-WebRequest -Uri $url -OutFile $output
# On installe silencieusement
Start-Process -FilePath $output -ArgumentList "/S" -Wait
Write-Host "Firefox a bien ete passe en version $latestVersion."
} else {
Write-Host "Firefox est a jour. Version: $installedVersion"
}