64 lines
2.4 KiB
PowerShell
64 lines
2.4 KiB
PowerShell
|
|
<#
|
||
|
|
Author: Gabe Kerntke
|
||
|
|
Date: 12-23-2023
|
||
|
|
|
||
|
|
.Synopsis
|
||
|
|
Script to install AmazonCorretto32 on machines that do not already have it
|
||
|
|
|
||
|
|
.Modified
|
||
|
|
2023-12-23 (GabeK) - Original script created
|
||
|
|
2025-08-07 (GabeK) - Rebuilt to use functions script
|
||
|
|
#>
|
||
|
|
|
||
|
|
[CmdletBinding()]
|
||
|
|
Param(
|
||
|
|
[Parameter(Mandatory = $false)]
|
||
|
|
$App_Name = "Amazon Corretto 8",
|
||
|
|
[Parameter(Mandatory = $false)]
|
||
|
|
$File_Name_Prefix = "Corretto-JDK-x32",
|
||
|
|
[Parameter(Mandatory = $false)]
|
||
|
|
$File_Name_Extension = "msi",
|
||
|
|
[Parameter(Mandatory = $false)]
|
||
|
|
$Install_Parameters = "/qn /norestart",
|
||
|
|
[Parameter(Mandatory = $false)]
|
||
|
|
$EPCache_Folder = "3rd Party Patches\$App_Name"
|
||
|
|
)
|
||
|
|
|
||
|
|
$Version_URL = "https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html"
|
||
|
|
$Program = (Invoke-WebRequest -UseBasicParsing "$Version_URL").Links.href -like "*msi*" -like "*jdk*" -like "*x86*" | Select-Object -First 1
|
||
|
|
$request = [System.Net.WebRequest]::Create($Program)
|
||
|
|
$request.AllowAutoRedirect = $false
|
||
|
|
$response = $request.GetResponse()
|
||
|
|
$Version = If ($response.StatusCode -eq "Found") { $response.GetResponseHeader("Location") }
|
||
|
|
$Online_Version = $Version.split("/") | Select-Object -First 4 | Select-Object -Last 1
|
||
|
|
$DownloadURL = "$Program"
|
||
|
|
$File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension"
|
||
|
|
|
||
|
|
#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*") {
|
||
|
|
|
||
|
|
#Get currently installed version
|
||
|
|
$Local_Version = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayVersion
|
||
|
|
|
||
|
|
#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
|