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] Dell Command | Update #69

Open AScott-WWF opened 3 weeks ago

AScott-WWF commented 3 weeks ago

I have written a new NeverGreen script to return the latest versions of Dell Command | Update for Windows, this is obtained using a webscrape against the Dell Command | Update Summary page https://www.dell.com/support/kbdoc/en-uk/000177325/dell-command-update

N.B. The downloads ($URL in my script) are obtained from their own sub page ($ReleaseURL in my script) links from the Summary page

# Get-DellCommandUpdate.ps1

$AppName = "Dell Command Update"
$SummaryURL = 'https://www.dell.com/support/kbdoc/en-uk/000177325/dell-command-update'
[version]$Version = Get-Version -Uri $SummaryURL -Pattern '- Dell Command \| Update (\d+\.\d+\.\d+)'
Write-Verbose "Version :: $Version"

$Platforms = @(
    @{Architecture = 'x86'; Platform = 'Windows Universal Application'; Language = 'Neutral'; Pattern = 'Dell Command \| Update Windows Universal Application'; Download = 'Dell-Command-Update-Windows-Universal-Application_.*?_WIN_.*?\.EXE'}
    @{Architecture = 'x86'; Platform = 'Windows Application (Classic)'; Language = 'Neutral'; Pattern = 'Dell Command \| Update Application \(Classic\)'; Download = 'Dell-Command-Update-Application_.*?_WIN_.*?\.EXE'}
)

foreach ($Platform in $Platforms) {
    $SearchCount = 2

    do {
        $ReleaseURL = Get-Link -Uri $SummaryURL -MatchProperty outerHTML -Pattern $Platform.Pattern
        #Write-Verbose "Release URL :: $ReleaseURL"

        $URL = Get-Link -Uri $ReleaseURL -MatchProperty href -Pattern $Platform.Download
        #Write-Verbose "Download URL :: $URL"

        if ($URL) {
            New-NevergreenApp -Name $($AppName) -Version $Version -Uri $URL -Architecture $Platform.Architecture -Platform $Platform.Platform -Language $Platform.Language -Type 'exe'
            break
        }
        $SearchCount--
    } until ($SearchCount -eq 0)

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