DanGough / Nevergreen

This module is an alternative to Evergreen, and allows you to find the latest version and download URL for various Windows apps. Evergreen uses API queries to obtain its data whereas this module is more focussed on web scraping. This is more prone to breaking when websites are changed, hence the name.
The Unlicense
71 stars 16 forks source link

[New App Request] Xerox Print Awareness Client (On Proposals list) #101

Open AScott-WWF opened 2 days ago

AScott-WWF commented 2 days ago

Script:

# Get-XeroxPrintAwarenessClient.ps1

# Define AppName
$AppName = "Xerox Print Awareness Client"

$ReleaseUrl = "https://www.support.xerox.com/en-us/product/xerox-print-awareness-tool/content/142452"

Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n"

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = $($AppName); Architecture = 'multi'; Type = 'zip'; Pattern = '*.zip'}
)

foreach ($AppVersion in $AppVersions) {
    $SearchCount = 1 # This may need increasing as future versions are released

    #Build each link with File Type specific versions
    #URLs on this page are encoded, so need to decode to be readable
    $DownloadLink = (((Invoke-WebRequest -Uri $ReleaseUrl).Links) | Where-Object {($_.href -like $($AppVersion.Pattern))}).href
    $URL = [System.Net.WebUtility]::HtmlDecode($DownloadLink)
    $Version = Get-Version -String $URL

    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Architecture $($AppVersion.Architecture) -Version $($Version) -Uri $($URL) -Type $($AppVersion.Type)
            break
        }

        $SearchCount--
    } until ($SearchCount -eq 0)

    if ($SearchCount -eq 0) {
        Write-Warning "Could not find release for $($AppName) $($AppVersion.Type)"
    }
}