Update App Install or Upgrade Scripts/App - 7zip - Install or Upgrade.ps1
This commit is contained in:
@@ -1,61 +1,61 @@
|
|||||||
<#
|
<#
|
||||||
Author: Gabe Kerntke
|
Author: Gabe Kerntke
|
||||||
Date: 04-25-2024
|
Date: 04-25-2024
|
||||||
|
|
||||||
.Synopsis
|
.Synopsis
|
||||||
Script to install 7zip on machines that do not already have it
|
Script to install 7zip on machines that do not already have it
|
||||||
|
|
||||||
.Modified
|
.Modified
|
||||||
2024-04-25 (GabeK) - Original script created
|
2024-04-25 (GabeK) - Original script created
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$App_Name = "7-zip",
|
$App_Name = "7-zip",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$File_Name_Prefix = "7zip-x64",
|
$File_Name_Prefix = "7zip-x64",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$File_Name_Extension = "exe",
|
$File_Name_Extension = "exe",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$Install_Parameters = "/S",
|
$Install_Parameters = "/S",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$EPCache_Folder = "3rd Party Patches\$App_Name",
|
$EPCache_Folder = "3rd Party Patches\$App_Name",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$initialURL = "https://www.7-zip.org/",
|
$initialURL = "https://www.7-zip.org/",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$Online_Version = $Version_URL.substring(4, $Version_URL.Length - 12) + ".0",
|
$Online_Version = $Version_URL.substring(4, $Version_URL.Length - 12) + ".0",
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$DownloadURL = $initialURL + $Version_URL,
|
$DownloadURL = $initialURL + $Version_URL,
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
$File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension"
|
$File_Name = "$File_Name_Prefix-$Online_Version.$File_Name_Extension"
|
||||||
)
|
)
|
||||||
$Version_URL = (Invoke-webRequest -UseBasicParsing $initialURL).Links.href | Where-Object { $_.EndsWith("exe") } | Select-Object -First 1
|
$Version_URL = (Invoke-webRequest -UseBasicParsing $initialURL).Links.href | Where-Object { $_.EndsWith("exe") } | Select-Object -First 1
|
||||||
|
|
||||||
#Region Script Start
|
#Region Script Start
|
||||||
If ((Test-Path "C:\Temp\Script Cache") -eq $False) { New-Item -ItemType directory -Path "C:\Temp\Script Cache" }
|
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"
|
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"
|
. "C:\Temp\Script Cache\Functions.ps1"
|
||||||
|
|
||||||
#Check to see if program is installed
|
#Check to see if program is installed
|
||||||
$Applist = Get-Software | Sort-Object -Descending
|
$Applist = Get-Software | Sort-Object -Descending
|
||||||
|
|
||||||
If ($Applist.DisplayName -like "*$App_Name*") {
|
If ($Applist.DisplayName -like "*$App_Name*") {
|
||||||
|
|
||||||
#Get currently installed version
|
#Get currently installed version
|
||||||
$Local_Version = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayVersion
|
$Local_Version = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayVersion
|
||||||
|
|
||||||
#Comparing version already installed to what is online
|
#Comparing version already installed to what is online
|
||||||
If ($Local_Version -lt $Online_Version) {
|
If ([version]$Local_Version -lt [version]$Online_Version) {
|
||||||
Test-Probe_Online
|
Test-Probe_Online
|
||||||
Close-App
|
Close-App
|
||||||
Install-App
|
Install-App
|
||||||
}
|
}
|
||||||
Else { Write-Host "$App_Name already on latest version (Installed version: $Local_Version)" }
|
Else { Write-Host "$App_Name already on latest version (Installed version: $Local_Version)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
Else {
|
Else {
|
||||||
Test-Probe_Online
|
Test-Probe_Online
|
||||||
Install-App
|
Install-App
|
||||||
}
|
}
|
||||||
#Region Script End
|
#Region Script End
|
||||||
Reference in New Issue
Block a user