Files
Powershell-Scripts/App Install Scripts/App - PCHealthCheck - Install.ps1
T

65 lines
2.4 KiB
PowerShell

<#
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 #