-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-OnlineVerAcrobatReader.ps1
More file actions
134 lines (115 loc) · 4.86 KB
/
Get-OnlineVerAcrobatReader.ps1
File metadata and controls
134 lines (115 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<#
.NOTES
===========================================================================
Created with: PowerShell ISE (Win10 17763)
Revision: v3
Last Modified: 16 September 2021
Created by: Jay Harper (github.com/thecatdidit/powershellusefulscripts)
Organizaiton: Happy Days Are Here Again
Filename: Get-OnlineVerAdobeReader.ps1
===========================================================================
.CHANGELOG
v3 (16 September 2021)
Corrected parsing to determine release date
v2 (09 June 2021)
Corrected site scraping/parsing RegEx to reflect a new layout of the Adobe
support site.
v1 (27 March 2019)
Script creation
.SYNOPSIS
Queries the Adobe Website for the current version of
Adobe Acrobat Reader DC. The script returns the version, date updated, and
download URLs if available.
.DESCRIPTION
This function retrieves the latest data associated with Adobe Reader.
Utilizes Invoke-WebRequest to query Adobe Reader's release notes pagean
and pulls out the Version, Update Date and Download URLs for
the app (x64 only) It then outputs the information as a
PSObject to the Host.
.EXAMPLE
PS C:\> Get-OnlineVerAdobeReader.ps1
Software_Name : Adobe Acrobat Reader DC
Software_URL : https://helpx.adobe.com/acrobat/release-note/release-notes-acrobat-reader.html
Online_Version : 21.005.20048
Online_Date : Jun 08, 2021
Download_URL_x64 : http://ardownload.adobe.com/pub/adobe/reader/win/AcrobatDC/2100520048/AcrodrDCUpd2100520048.msp
PS C:\> Get-OnlineVerAdobeReader.ps1 -Quiet
21.005.20048
.INPUTS
-Quiet
Use of this parameter will output just the current version of
Adobe Reader instead of the entire object. It will always be the
last parameter.
.OUTPUTS
An object containing the following:
Software Name: Name of the software
Software URL: The URL info was sourced from
Online Version: The current version found
Online Date: The date the version was updated
If -Quiet is specified then just the value of 'Online Version'
will be displayed.
.NOTES
Resources/Credits:
https://github.com/itsontheb
#>
function Get-OnlineVerAdobeReader {
[cmdletbinding()]
param (
[Parameter(Mandatory = $false,
Position = 0)]
[switch]
$Quiet
)
begin {
# Initial Variables
$softwareName = 'Adobe Acrobat Reader DC'
$uri = 'https://helpx.adobe.com/acrobat/release-note/release-notes-acrobat-reader.html'
$hashtable = [ordered]@{
'Software_Name' = $softwareName
'Software_URL' = $uri
'Online_Version' = 'UNKNOWN'
'Online_Date' = 'UNKNOWN'
'Download_URL_x64' = 'UNKNOWN'
}
$swObject = New-Object -TypeName PSObject -Property $hashtable
}
Process {
# Get the Version & Release Date
try {
$VersionRegex = "\d+(\.\d+)+"
$html = Invoke-WebRequest -UseBasicParsing -Uri "$uri"
$DC_Versions = $html.Links | Where-Object outerHTML -Match "\($VersionRegex\)"
$versionArray = @()
foreach ($version in $DC_Versions) {
$VersionNumber = [regex]::match($Version.outerHTML , "$VersionRegex").Value
$versionArray += $VersionNumber
}
$adobeVersion = $versionArray[0]
$site = (Invoke-WebRequest -Uri $uri -UseBasicParsing | Select-Object -ExpandProperty Content)
$site -match "<th valign=""top""><p><b>Focus</b></p>`n</th>`n</tr><tr><td>(?<date>.*)<br />" | Out-Null
$adobeDate = ($matches['date'])
$urlData = $adobeVersion.Replace(".", "")
$downloadURL = 'https://ardownload.adobe.com/pub/adobe/reader/win/AcrobatDC/' + $urlData + "/AcrodrDCUpd" + $urlData + ".msp"
$swObject.Download_URL_x64 = $downloadURL
$swObject.Online_Version = $adobeVersion
$swObject.Online_Date = $adobeDate
}
catch {
Write-Verbose -Message "Error accessing the below URL: `n $URI"
$message = $("Line {0} : {1}" -f $_.InvocationInfo.ScriptLineNumber, $_.exception.message)
$swObject | Add-Member -MemberType NoteProperty -Name 'ERROR' -Value $message
}
finally {
}
}
End {
# Output to Host
if ($Quiet) {
Write-Verbose -Message '$Quiet was specified. Returning just the version'
Return $swObject.Online_Version
}
else {
Return $swobject
}
}
} # END Function Get-OnlineVerAdobeReader