Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # URL of Adobe's app version page
- $url = "https://helpx.adobe.com/uk/enterprise/kb/adobe-cc-app-base-versions.html"
- # Download the full HTML content using curl
- Write-Host "Fetching live HTML from Adobe..."
- $html = curl $url | Out-String
- Write-Host "Downloaded $($html.Length) characters.`n"
- # Find the section where version tables begin
- $marker = "Current base versions of apps (version N)"
- $markerIndex = $html.IndexOf($marker)
- if ($markerIndex -lt 0) { throw "Marker text not found." }
- # Extract only the HTML after the marker to limit scope
- $htmlAfterMarker = $html.Substring($markerIndex)
- # Identify and extract all <table> blocks after the marker
- $tableMatches = [regex]::Matches($htmlAfterMarker, "(?is)<table.*?>.*?</table>")
- $tableHtmls = $tableMatches | ForEach-Object { $_.Value }
- Write-Host "Found $($tableHtmls.Count) tables after marker.`n"
- # Parse a single HTML table into a list of PSObjects
- function Convert-TableHtml {
- param ([string]$tableHtml)
- # Removes HTML tags and non-printable characters from cell content
- function StripHtml {
- param($text)
- $clean = $text -replace "<.*?>", ""
- $asciiOnly = [System.Text.RegularExpressions.Regex]::Replace($clean, "[^\u0020-\u007E]", " ")
- return ($asciiOnly -replace "\s+", " ").Trim()
- }
- # Extract rows from <tr> tags
- $rows = [regex]::Matches($tableHtml, "(?is)<tr[^>]*>.*?</tr>")
- if ($rows.Count -eq 0) { return @() }
- # Clean and normalize header cells from first row
- $headerCells = [regex]::Matches($rows[0].Value, "(?is)<t[dh][^>]*>(.*?)</t[dh]>")
- $headers = $headerCells | ForEach-Object { StripHtml $_.Groups[1].Value }
- # Parse each remaining row and map data to headers
- $rows = $rows[1..($rows.Count - 1)]
- $data = @()
- foreach ($row in $rows) {
- $cells = [regex]::Matches($row.Value, "(?is)<td[^>]*>(.*?)</td>") | ForEach-Object { StripHtml $_.Groups[1].Value }
- $obj = [ordered]@{}
- for ($i = 0; $i -lt $headers.Count; $i++) {
- $obj[$headers[$i]] = if ($i -lt $cells.Count) { $cells[$i] } else { "" }
- }
- $data += New-Object PSObject -Property $obj
- }
- return $data
- }
- # Parse and sort Current Versions table
- $currentRaw = Convert-TableHtml $tableHtmls[0]
- # Sort Current Versions: Sap Code ascending, Base version descending
- $currentSorted = $currentRaw | Sort-Object `
- @{ Expression = { $_.'Sap Code' }; Descending = $false },
- @{ Expression = {
- # Pad each segment of version number for accurate descending sort
- $ver = ($_.'Base version' -replace "[^\d\.]", "") -split "\."
- ($ver | ForEach-Object { "{0:D4}" -f ($_ -as [int]) }) -join "."
- }; Descending = $true }
- Write-Host "`n=== Current Base Versions (Sorted) ==="
- $currentSorted | Format-Table -AutoSize
- # Parse and combine all Previous Versions tables
- $previousTableHtmls = $tableHtmls[1..($tableHtmls.Count - 1)]
- $previousVersions = @()
- foreach ($htmlBlock in $previousTableHtmls) {
- $previousVersions += Convert-TableHtml $htmlBlock
- }
- # Build a set of known current Sap Code + Base version combos
- $currentPairs = $currentSorted | ForEach-Object {
- "$($_.'Sap Code')|$($_.'Base version')"
- }
- # Remove any Previous Versions rows that match a Current Version
- $filteredPrevious = $previousVersions | Where-Object {
- "$($_.'Sap Code')|$($_.'Base version')" -notin $currentPairs
- }
- # Deduplicate repeated Sap Code + Base version entries
- # For each group, retain the row with the longest Platform IDs string
- $deduplicatedPrevious = $filteredPrevious | Group-Object {
- "$($_.'Sap Code')|$($_.'Base version')"
- } | ForEach-Object {
- $_.Group | Sort-Object {
- ($_. 'Platform IDs for applicable platforms' ).Length
- } -Descending | Select-Object -First 1
- }
- # Final sort: Sap Code asc, Base version desc
- $sortedPrevious = $deduplicatedPrevious | Sort-Object `
- @{ Expression = { $_.'Sap Code' }; Descending = $false },
- @{ Expression = {
- $ver = ($_.'Base version' -replace "[^\d\.]", "") -split "\."
- ($ver | ForEach-Object { "{0:D4}" -f ($_ -as [int]) }) -join "."
- }; Descending = $true }
- # Display cleaned, deduplicated previous versions table
- Write-Host "`n=== All Previous Versions (Deduplicated, Sorted) ==="
- $sortedPrevious | Format-Table -AutoSize
- # Combine Sap Code and Base version into command-line format
- $versionPairs = $sortedPrevious | ForEach-Object {
- "$($_.'Sap Code')#$($_.'Base version')"
- }
- # Output ready-to-run uninstaller command
- $summaryString = "AdobeUninstaller.exe --products=" + ($versionPairs -join ",") + " --skipNotInstalled"
- Write-Host "`n=== Adobe Uninstaller Command ==="
- Write-Host $summaryString
Advertisement
Add Comment
Please, Sign In to add comment