From 80146624769814df7aa2c34f99d627f42628ef46 Mon Sep 17 00:00:00 2001 From: Gabe Date: Thu, 7 Aug 2025 18:50:07 +0000 Subject: [PATCH] Upload files to "App Install Scripts" --- .../App - PCHealthCheck - Install.ps1 | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 App Install Scripts/App - PCHealthCheck - Install.ps1 diff --git a/App Install Scripts/App - PCHealthCheck - Install.ps1 b/App Install Scripts/App - PCHealthCheck - Install.ps1 new file mode 100644 index 0000000..a02050b --- /dev/null +++ b/App Install Scripts/App - PCHealthCheck - Install.ps1 @@ -0,0 +1,65 @@ +<# +Author: Marc Wolf +Date: 03-19-2024 + +.Synopsis + +.Modified +2024-03-19 (MarcW) - Original script created +2024-10-07 (GabeK) - Updated script +2024-10-22 (GabeK) - Script updated to work more consistently and added reg settings +2025-05-05 (GabeK) - Script updated to use functions script +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory = $false)] + $App_Name = "WindowsPCHealthCheckSetup", + [Parameter(Mandatory = $false)] + $File_Name_Extension = "msi", + [Parameter(Mandatory = $false)] + $Install_Parameters = "/qn", + [Parameter(Mandatory = $false)] + $EPCache_Folder = "3rd Party Patches\$App_Name", + [Parameter(Mandatory = $false)] + $DownloadURL = "https://aka.ms/GetPCHealthCheckApp", + [Parameter(Mandatory = $false)] + $File_Name = "$App_Name.$File_Name_Extension" +) + +# Functions # + +Function Set-RegKeys { + New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS + Start-Sleep 5 + + $GetPaths = Get-ChildItem "HKU:\" -ErrorAction SilentlyContinue | Select-Object -Skip 1 -ExpandProperty Name + $RegPaths = $GetPaths.replace('HKEY_USERS\', '') + $Location = foreach ($Path in $RegPaths) { + Get-ChildItem "HKU:\$Path\Software\Microsoft" -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "*PCHC*" } | Select-Object -ExpandProperty PSPath + Get-ChildItem "HKU:\$Path\Software\Microsoft" -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "*PCHealthCheck*" } | Select-Object -ExpandProperty PSPath + } + New-ItemProperty -Path $Location.substring(26) -Name "UpgradeEligibility" -Value 1 -Type DWORD -Force -Verbose +} + +#Region Script Start +If ((Test-Path "C:\Temp\Script Cache") -eq $False) { New-Item -ItemType directory -Path "C:\Temp\Script Cache" } +#Use TLS 1.2 for communication +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +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 if App is installed +$Applist = Get-Software | Sort-Object -Descending +Start-Sleep 5 + +If ($Applist.DisplayName -notlike "*$App_Name*") { + Test-Probe_Online + Install-App + Set-RegKeys +} +Else { + Write-Host "$App_Name is installed, exiting script." + Set-RegKeys +} +# End Script # \ No newline at end of file