diff --git a/App Update Scripts/App - Adobe - Update.ps1 b/App Update Scripts/App - Adobe - Update.ps1 new file mode 100644 index 0000000..e12e272 --- /dev/null +++ b/App Update Scripts/App - Adobe - Update.ps1 @@ -0,0 +1,157 @@ +<# +Author: Gabe Kerntke +Date: 07-19-2024 + +.Synopsis +Script to update Adobe on machines +Checks online for the newest version and will either grab it from the probe if it has it or download it from online and updates to that newest version. +Will update either 64 or 32 bit version(whichever is detected) +Does both Reader and Acrobat Pro versions + +.Modified +2024-07-19 (GabeK) - Original script created +2025-07-01 (GabeK) - Updated script to use functions script +2025-07-30 (GabeK) - Updated script to find pro vs standard reader versions +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory = $false)] + $App_Name = "Adobe Acrobat", + [Parameter(Mandatory = $false)] + $File_Name_Extension = "msp", + [Parameter(Mandatory = $false)] + $Install_Parameters = "/quiet /norestart", + [Parameter(Mandatory = $false)] + $EPCache_Folder = "3rd Party Patches\$App_Name" +) + +# Define a script block that contains the Invoke-WebRequest command +$scriptBlock = { + (Invoke-WebRequest -UseBasicParsing -Headers @{ + "accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" + "accept-encoding" = "gzip, deflate, br" + "accept-language" = "en-GB,en;q=0.9,en-US;q=0.8" + } -Uri "https://www.adobe.com/devnet-docs/acrobatetk/tools/ReleaseNotesDC/index.html#").Links.outerHTML -like "*continuous/*" | Select-Object -First 2 | Select-Object -Last 1 +} +#Start a new PowerShell background job and pass the script block to it +$job = Start-Job -ScriptBlock $scriptBlock + +#Wait for the job to complete +$timeout = 30 +Wait-Job $job -timeout $timeout | Out-Null + +#Get the output from the job and display it +$output = Receive-Job $job +$A = $output.Substring(125) +$B = $A.Substring(0, $A.Length - 38) +$Online_Version = $B -replace "[^\d*\.?\d*$/]" , '' + +#Gets second half of URL of newest version +$psi = New-Object System.Diagnostics.ProcessStartInfo +$psi.FileName = 'powershell.exe' +$psi.Arguments = "(Invoke-WebRequest -UseBasicParsing -Headers @{ + 'accept'='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' + 'accept-encoding'='gzip, deflate, br' + 'accept-language'='en-GB,en;q=0.9,en-US;q=0.8' + } -Uri 'https://www.adobe.com/devnet-docs/acrobatetk/tools/ReleaseNotesDC/index.html#').Links.href -like 'continuous/*' | Select-Object -First 1" +$psi.RedirectStandardOutput = $true +$psi.UseShellExecute = $false + +$process = [System.Diagnostics.Process]::Start($psi) +$output = $process.StandardOutput.ReadToEnd() +$process.WaitForExit() + +#combines the first and second half URLs for latest version's URL +$CombinedURL = "https://www.adobe.com/devnet-docs/acrobatetk/tools/ReleaseNotesDC/$output" + +# Functions # +Function Get-Download_URL { + #gets link + $psi = New-Object System.Diagnostics.ProcessStartInfo + $psi.FileName = 'powershell.exe' + $psi.Arguments = "(Invoke-WebRequest -UseBasicParsing -Headers @{ + 'accept'='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' + 'accept-encoding'='gzip, deflate, br' + 'accept-language'='en-GB,en;q=0.9,en-US;q=0.8' + } -Uri $CombinedURL).Links.href -like '$MSP_File'" + $psi.RedirectStandardOutput = $true + $psi.UseShellExecute = $false + + $process = [System.Diagnostics.Process]::Start($psi) + $output = $process.StandardOutput.ReadToEnd() + $process.WaitForExit() + Return $output +} + +Function Install-Adobe { + #Get currently installed version + $Local_Version = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayVersion + . "C:\Temp\Script Cache\Functions.ps1" + + #Comparing version already installed to what is online + If ([version]$Local_Version -lt [version]$Online_Version) { + Test-Probe_Online + Close-App + Install-App + } + Else { Write-Host "$App_Name already on latest version (Installed version: $Local_Version)" } +} + +#Region Script Start +If ((Test-Path "C:\Temp\Script Cache") -eq $False) { New-Item -ItemType directory -Path "C:\Temp\Script Cache" } +Invoke-WebRequest -UseBasicParsing "https://scripts.gabesville.com/Gabesville/Powershell-Scripts/raw/branch/main/Functions%20Scripts/Functions.ps1" -outfile "C:\Temp\Script Cache\Functions.ps1" +. "C:\Temp\Script Cache\Functions.ps1" + +#Check to see if program is installed +$Applist = Get-Software | Sort-Object -Descending + +If ($Applist.DisplayName -like "*$App_Name*64-bit*") { + $SCAPackageLevel = Get-ItemProperty -Path "HKLM:\SOFTWARE\Adobe\Adobe Acrobat\DC\Installer\" -Name "SCAPackageLevel" | Select-Object -ExpandProperty SCAPackageLevel + $InstallPathx64 = "C:\Program Files\Adobe\Acrobat DC\Acrobat" + If ($SCAPackageLevel -eq 1) { + Write-Host "Adobe Reader is installed, SCAPackageLevel=$SCAPackageLevel" + If (Test-Path "$InstallPathx64\ReaderMenuCoreApp.msix") { + Write-Host "Adobe Reader verified via path." + $File_Name_Prefix = "Adobe-Reader-x64" + $File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension" + $MSP_File = "*AcroRdrDCx64*_MUI.msp" + $DownloadURL = Get-Download_URL + Install-Adobe + } + } + ElseIf ($SCAPackageLevel -ne 1) { + Write-Host "Adobe Acrobat Pro is installed, SCAPackageLevel=$SCAPackageLevel" + If (Test-Path "$InstallPathx64\AcrobatMenuCoreApp.msix") { + Write-Host "Adobe Acrobat Pro verified via path." + $File_Name_Prefix = "Adobe-Acrobat-x64" + $File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension" + $MSP_File = '*AcrobatDCx64*' + $DownloadURL = Get-Download_URL + Install-Adobe + } + } +} + +Elseif ($Applist.DisplayName -like "$App_Name*") { + $InstallPathx32 = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader" + #Test-Path "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" + If (Test-Path "$InstallPathx32\ReaderMenuCoreApp.msix") { + Write-Host "Adobe Reader installed, verified via path." + $File_Name_Prefix = "Adobe-Reader-x32" + $File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension" + $MSP_File = "*AcroRdrDCUpd*_MUI.msp" + $DownloadURL = Get-Download_URL + Install-Adobe + } + ElseIf (Test-Path "$InstallPathx32\AcrobatMenuCoreApp.msix") { + Write-Host "Adobe Acrobat Pro installed, verified via path." + $File_Name_Prefix = "Adobe-Acrobat-x32" + $File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension" + $MSP_File = '*AcrobatDCUpd*' + $DownloadURL = Get-Download_URL + Install-Adobe + } +} +Else { Write-Host "$App_Name not installed, exiting script" } +#Region Script End \ No newline at end of file