From 0028bdc83b5d9cdd5e070a88da2fc94b3493b934 Mon Sep 17 00:00:00 2001 From: Gabe Date: Fri, 8 Aug 2025 14:15:47 +0000 Subject: [PATCH] Upload files to "App Install or Upgrade Scripts" --- .../App - Java64 - Install or Upgrade.ps1 | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 App Install or Upgrade Scripts/App - Java64 - Install or Upgrade.ps1 diff --git a/App Install or Upgrade Scripts/App - Java64 - Install or Upgrade.ps1 b/App Install or Upgrade Scripts/App - Java64 - Install or Upgrade.ps1 new file mode 100644 index 0000000..9440038 --- /dev/null +++ b/App Install or Upgrade Scripts/App - Java64 - Install or Upgrade.ps1 @@ -0,0 +1,78 @@ +<# +Author: Gabe Kerntke +Date: 06-10-2024 + +.Synopsis +Script to install Java 64bit on machines that do not already have it or upgrade to the newest version if behind + +.Modified +2024-06-10 (GabeK) - Original script created +2025-08-08 (GabeK) - Rebuilt to use functions script +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory = $false)] + $App_Name = "Java 8 Update", + [Parameter(Mandatory = $false)] + $File_Name_Prefix = "jre-x64", + [Parameter(Mandatory = $false)] + $File_Name_Extension = "exe", + [Parameter(Mandatory = $false)] + $Install_Parameters = "/s REMOVEOLDERJRES=1", + [Parameter(Mandatory = $false)] + $EPCache_Folder = "3rd Party Patches\$App_Name", + [Parameter(Mandatory = $false)] + $File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension" +) +# Adjustable Variables +$mapXML = Invoke-RestMethod "https://javadl-esd-secure.oracle.com/update/1.8.0/map-1.8.0.xml" -UserAgent 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46' + +#Select latest build from entries marked as 'critical' +$target = ($mapXML.'java-update-map'.mapping | Where-Object { $_.critical -eq 1 } | Select-Object -Last 1) + +$params = @{ + 'Uri' = [string]$target.url + 'ContentType' = 'application/xml' + 'UserAgent' = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46' +} +$javaXml = Invoke-RestMethod @params + +#substituting the 'au' (automatic update) value in the url with the desired architecture. +$javaUpdateInfo = $javaXml.'java-update'.information +$DownloadURL = [string]($javaUpdateInfo.url) -replace '\-au', "-x64" + +#finds latest version from online +$A = $DownloadURL.substring(115) +$B = $A.Substring(0, $A.Length - 26) +$Online_Version = $B -replace ("U", ".") + +#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*") { + + #Get currently installed version + $A = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*64-bit*" } | Select-Object -ExpandProperty DisplayVersion + $B = $A.Substring(4) + $LocalVersion = "8." + $B.Substring(0, $B.Length - 3) + + #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)" } +} + +Else { + Test-Probe_Online + Install-App +} +#Region Script End \ No newline at end of file