Repository navigation
Expand file tree
/
Copy pathapp_deployment.ps1
More file actions
179 lines (155 loc) · 6.91 KB
/
Copy pathapp_deployment.ps1
File metadata and controls
179 lines (155 loc) · 6.91 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Set working directory
$workDir = "C:\ProgramData\AppDeploy"
New-Item -ItemType Directory -Path $workDir -Force | Out-Null
Set-Location $workDir
# Function to download files
function Download-File {
param (
[string]$url,
[string]$destination
)
if (-not (Test-Path $destination)) {
Invoke-WebRequest -Uri $url -OutFile $destination -UseBasicParsing
} else {
Write-Output "$destination already exists. Skipping download."
}
}
# Function to check if app is installed
function Is-AppInstalled {
param([string]$name)
$keys = @(
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
)
foreach ($key in $keys) {
$installed = Get-ItemProperty $key -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*$name*" }
if ($installed) { return $true }
}
return $false
}
# Function to get the latest version and download URL of Adobe Acrobat Reader DC
function Get-AdobeAcrobatReaderDCUrls {
[CmdletBinding()]
param ()
# URL of the Adobe Acrobat Reader DC release notes page
$apiUrl = 'https://helpx.adobe.com/acrobat/release-note/release-notes-acrobat-reader.html'
Write-Debug "Fetching main release notes page: $apiUrl"
try {
# Fetch the main release notes page using curl.exe
$response = curl.exe -s $apiUrl
if ($response) {
$htmlContent = $response
Write-Debug "Main release notes page content fetched."
} else {
throw "Failed to fetch main release notes page."
}
} catch {
# Handle errors in fetching the main release notes page
Write-Debug "Error fetching main release notes page: $_"
Write-Output "Error fetching main release notes page: $_"
exit
}
# Extract the first <a> link that matches the specified pattern
$linkPattern = [regex]::new('<a href="(https://www\.adobe\.com/devnet-docs/acrobatetk/tools/ReleaseNotesDC/[^"]+)"[^>]*>(DC [^<]+)</a>', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
$linkMatch = $linkPattern.Match($htmlContent)
Write-Debug "Searching for the first release notes link..."
if ($linkMatch.Success) {
# Extract the release notes URL and version from the matched link
$releaseNotesUrl = $linkMatch.Groups[1].Value
$version = $linkMatch.Groups[2].Value
Write-Debug "Release Notes URL: $releaseNotesUrl"
Write-Debug "Version: $version"
# Fetch the release notes page to get the .msp file link
Write-Debug "Fetching release notes page: $releaseNotesUrl"
try {
$releaseNotesResponse = curl.exe -s $releaseNotesUrl
if ($releaseNotesResponse) {
$releaseNotesContent = $releaseNotesResponse
Write-Debug "Release notes page content fetched."
} else {
throw "Failed to fetch release notes page."
}
} catch {
# Handle errors in fetching the release notes page
Write-Debug "Error fetching release notes page: $_"
Write-Output "Error fetching release notes page: $_"
exit
}
# Find the .msp file link in the release notes page
$mspLinkPattern = [regex]::new('<a[^>]+href="([^"]+\.msp)"[^>]*>([^<]+)</a>', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
$mspLinkMatch = $mspLinkPattern.Match($releaseNotesContent)
Write-Debug "Searching for the .msp file link..."
if ($mspLinkMatch.Success) {
# Extract the .msp file URL and version
$mspUrl = $mspLinkMatch.Groups[1].Value
Write-Debug "MSP URL: $mspUrl"
$mspFileName = [System.IO.Path]::GetFileNameWithoutExtension($mspUrl)
$mspVersion = $mspFileName -replace '.*?(\d{4,}).*', '$1'
Write-Debug "Extracted MSP Version: $mspVersion"
# Construct the download URLs for the MUI installer and MSP update files
$MUIurl = "https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/$mspVersion/AcroRdrDC${mspVersion}_MUI.exe"
Write-Debug "MUI URL: $MUIurl"
$MUIurl64 = "https://ardownload2.adobe.com/pub/adobe/acrobat/win/AcrobatDC/$mspVersion/AcroRdrDCx64${mspVersion}_MUI.exe"
Write-Debug "MUI URL 64-bit: $MUIurl64"
$MUImspURL = "https://ardownload2.adobe.com/pub/adobe/reader/win/AcrobatDC/$mspVersion/AcroRdrDCUpd${mspVersion}_MUI.msp"
Write-Debug "MUI MSP URL: $MUImspURL"
$MUImspURL64 = "https://ardownload2.adobe.com/pub/adobe/acrobat/win/AcrobatDC/$mspVersion/AcroRdrDCx64Upd${mspVersion}_MUI.msp"
Write-Debug "MUI MSP URL 64-bit: $MUImspURL64"
# Write-Output [PSCustomObject]@{
# Version = $version
# ReleaseNotesUrl = $releaseNotesUrl
# MUIurl = $MUIurl
# MUIurl64 = $MUIurl64
# MUImspURL = $MUImspURL
# MUImspURL64 = $MUImspURL64
# }
# Return the extracted information as a PowerShell custom object
return $MUIurl64
} else {
# Handle cases where the .msp file link is not found
Write-Debug "MSP file link not found."
Write-Output "MSP file link not found."
exit
}
} else {
# Handle cases where the version link is not found
Write-Debug "Version link not found."
Write-Output "Version link not found."
exit
}
}
# Example usage
$latest = Get-AdobeAcrobatReaderDCUrls
# Write the latest version and URLs
$latest
# 1. Adobe Reader DC
if (-not (Is-AppInstalled "Adobe Acrobat Reader")) {
Write-Output "Installing Adobe Reader..."
$adobeUrl = $latest
$adobeExe = "$workDir\AdobeReader.exe"
Download-File $adobeUrl $adobeExe
Start-Process $adobeExe -ArgumentList "/sAll /rs /rps /msi EULA_ACCEPT=YES /quiet" -Wait
} else {
Write-Output "✅ Adobe Reader is already installed. Skipping."
}
# 2. Google Chrome
if (-not (Is-AppInstalled "Google Chrome")) {
Write-Output "Installing Google Chrome..."
$chromeUrl = "https://dl.google.com/chrome/install/375.126/chrome_installer.exe"
$chromeExe = "$workDir\Chrome.exe"
Download-File $chromeUrl $chromeExe
Start-Process $chromeExe -ArgumentList "/silent /install" -Wait
} else {
Write-Output "✅ Google Chrome is already installed. Skipping."
}
# 3. Zoom
if (-not (Is-AppInstalled "Zoom")) {
Write-Output "Installing Zoom..."
$zoomUrl = "https://zoom.us/client/latest/ZoomInstallerFull.msi"
$zoomMsi = "$workDir\Zoom.msi"
Download-File $zoomUrl $zoomMsi
Start-Process msiexec.exe -ArgumentList "/i `"$zoomMsi`" /quiet /norestart" -Wait
} else {
Write-Output "✅ Zoom is already installed. Skipping."
}
Write-Host "`n✅ Finished. Reboot may be required."