UpdateWaterfox.ps1


<#PSScriptInfo

.VERSION 0.0.7

.GUID 7fc93349-b2de-47bd-88b1-391ee40b9131

.AUTHOR Fabrice Sanga

.COMPANYNAME sangafabrice

.COPYRIGHT © 2022 SangaFabrice. All rights reserved.

.TAGS waterfox update browser

.LICENSEURI https://github.com/sangafabrice/reg-cli/blob/main/LICENSE.md

.PROJECTURI https://github.com/sangafabrice/reg-cli/tree/waterfox

.ICONURI https://rawcdn.githack.com/sangafabrice/reg-cli/23e5f570257898bbf23d5341b94c4e7b86869328/icon.svg

.EXTERNALMODULEDEPENDENCIES DownloadInfo,RegCli

.REQUIREDSCRIPTS

.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES
Remove Select-NonEmptyObject from script.
Remove object selector.

.PRIVATEDATA

#>


#Requires -Module @{ModuleVersion = '5.0.4'; ModuleName = 'DownloadInfo'}
#Requires -Module @{ModuleVersion = '6.2.3'; ModuleName = 'RegCli'}

[CmdletBinding()]
Param (
    [ValidateNotNullOrEmpty()]
    [ValidateScript({ Test-InstallLocation $_ $PSScriptRoot })]
    [string]
    $InstallLocation = "${Env:ProgramData}\Waterfox",
    [ValidateNotNullOrEmpty()]
    [ValidateScript({ Test-InstallerLocation $_ })]
    [string]
    $SaveTo = $PSScriptRoot
)

& {
    Try {
        $UpdateModule =
            Import-CommonScript chrome-installer |
            Import-Module -PassThru -Force -Verbose:$False
        @{
            UpdateInfo = $(
                Try {
                    Write-Verbose 'Retrieve install or update information...'
                    Get-DownloadInfo -PropertyList @{
                        RepositoryId = 'WaterfoxCo/Waterfox'
                        AssetPattern = 'Setup\.exe$'
                    }
                }
                Catch { }
            )
            NameLocation = "$InstallLocation\waterfox.exe"
            SaveTo = $SaveTo
            SoftwareName = 'Waterfox'
            UseTimestamp = $True
            Verbose = $VerbosePreference -ine 'SilentlyContinue'
        } | ForEach-Object { Invoke-CommonScript @_ }
    }
    Catch { }
    Finally { $UpdateModule | Remove-Module -Verbose:$False }
}

<#
.SYNOPSIS
    Updates Waterfox browser software.
.DESCRIPTION
    The script installs or updates Waterfox browser on Windows.
.NOTES
    Required: at least Powershell Core 7.
.PARAMETER InstallLocation
    Path to the installation directory.
    It is restricted to file system paths.
    It does not necessary exists.
    It defaults to %ProgramData%\Waterfox.
.PARAMETER SaveTo
    Path to the directory of the downloaded installer.
    It is an existing file system path.
    It defaults to the script directory.
.EXAMPLE
    Get-ChildItem C:\ProgramData\Waterfox -ErrorAction SilentlyContinue

    PS > .\UpdateWaterfox.ps1 -InstallLocation C:\ProgramData\Waterfox -SaveTo .

    PS > Get-ChildItem C:\ProgramData\Waterfox | Select-Object Name -First 5
    Name
    ----
    browser
    defaults
    fonts
    gmp-clearkey
    uninstall

    PS > Get-ChildItem | Select-Object Name
    Name
    ----
    waterfox_G4.1.5.exe
    UpdateWaterfox.ps1

    Install Waterfox browser to 'C:\ProgramData\Waterfox' and save its setup installer to the current directory.
#>