100 lines
3.6 KiB
PowerShell
100 lines
3.6 KiB
PowerShell
<#
|
|
Author: Gabe Kerntke
|
|
Date: 05-04-2026
|
|
|
|
.Synopsis
|
|
Module for testing, downloading, installing, and verifying of apps from Artifactory
|
|
|
|
.Modified
|
|
2026-05-04 (GabeK) - Original script created
|
|
#>
|
|
|
|
Set-StrictMode -Version 2.0
|
|
|
|
#Region Functions
|
|
#Function checks for 32 or 64 bit processor and then pulls list of applications accordingly
|
|
Function Get-Software ($CPU = $ENV:PROCESSOR_ARCHITECTURE) {
|
|
If ($CPU -eq 'AMD64') {
|
|
$64bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
|
|
$32bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
|
|
$32bit + $64bit
|
|
}
|
|
Else { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* }
|
|
}
|
|
|
|
#Function to test if communication with the Artifactory is possible
|
|
Function Test-Artifactory {
|
|
$JFrog_URL = "https://URLHERE:PORT"
|
|
try {
|
|
$JFrog_Test = Invoke-WebRequest $JFrog_URL | Select-Object -ExpandProperty StatusCode
|
|
}
|
|
catch {
|
|
Write-Output "URL does not accept current TLS settings:"
|
|
[Net.ServicePointManager]::SecurityProtocol
|
|
Write-Output "`n"
|
|
Write-Output "Adding TLS 1.2"
|
|
#Adds TLS version 1.2 for communication
|
|
[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
|
$JFrog_Test = Invoke-WebRequest $JFrog_URL | Select-Object -ExpandProperty StatusCode
|
|
}
|
|
|
|
If ($JFrog_Test -eq "200") {
|
|
return $true
|
|
}
|
|
Else {
|
|
Write-Output "Error: $JFrog_Test"
|
|
Write-Output "Can't communicate with the $JFrog_URL. Exiting"
|
|
Exit
|
|
}
|
|
}
|
|
|
|
#Lists installers from Artifactory
|
|
Function Get-Installer_List_Artifactory {
|
|
$Artifactory_Full_Path = "$Artifactory_URL/api/storage$Artifactory_Installer_Path"
|
|
|
|
# Show files only
|
|
Invoke-RestMethod -Uri $Artifactory_Full_Path -Credential $Creds | Select-Object -ExpandProperty children |
|
|
Select-Object -ExpandProperty uri | Sort-Object -Descending | Select-Object -First 1
|
|
}
|
|
|
|
Function Get-From_Artifactory {
|
|
$Download_URL = $Artifactory_URL + $Artifactory_Installer_Path + $Installer_Name
|
|
# Ensure the folder exists
|
|
If ((Test-Path $Dest_Path) -eq $False) {
|
|
New-Item -ItemType directory -Path $Dest_Path
|
|
}
|
|
Invoke-WebRequest $Download_URL -Credential $Creds -OutFile $Dest_File
|
|
}
|
|
|
|
#Function to install the downloaded installer
|
|
Function Install-App {
|
|
$Install = Start-Process $Dest_File -ArgumentList $Install_Parameters -Wait -PassThru
|
|
$ExitCode = ($Install).ExitCode
|
|
Read-ExitCode -exitcode $ExitCode
|
|
}
|
|
|
|
#Function checks the exitcode
|
|
Function Read-ExitCode {
|
|
If ($ExitCode -eq 0) {
|
|
Write-Host "Script was Successful"
|
|
Start-Sleep 10
|
|
(Get-Software | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like "*$App_Name*" } | Format-List | Out-string).Trim()
|
|
Remove-Item $Dest_File -Force -ErrorAction SilentlyContinue
|
|
}
|
|
ElseIf ($ExitCode -eq 3010) {
|
|
Write-Host "Script was Successful, but a reboot is required."
|
|
Start-Sleep 10
|
|
(Get-Software | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like "*$App_Name*" } | Format-List | Out-string).Trim()
|
|
Remove-Item $Dest_File -Force -ErrorAction SilentlyContinue
|
|
}
|
|
ElseIf ($ExitCode -eq 1642) {
|
|
Write-Host "MUI version not detected, please reinstall Adobe to update."
|
|
Remove-Item $Dest_File -Force -ErrorAction SilentlyContinue
|
|
}
|
|
Else {
|
|
Write-Host `n
|
|
Write-Host "Failed... Exit Code:"$ExitCode
|
|
Remove-Item $Dest_File -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
#EndRegion |