diff --git a/App Update Scripts/App - .NET 8 - Update.ps1 b/App Update Scripts/App - .NET 8 - Update.ps1 index d88f5e8..9ae75f5 100644 --- a/App Update Scripts/App - .NET 8 - Update.ps1 +++ b/App Update Scripts/App - .NET 8 - Update.ps1 @@ -1,129 +1,128 @@ -<# -Author: Gabe Kerntke -Company: UFS LLC -Date: 07-14-2025 - -.Synopsis -Script to update .NET 8 - -.Modified -2025-07-14 (GabeK) - Original script created - -.PARAMETER VersionPattern - Regex pattern to grab all h3 headers on the $URL page - -.PARAMETER downloadLinkPattern - Regex pattern as a wildcard -#> - -[CmdletBinding()] -Param( - [Parameter(Mandatory = $false)] - $File_Name_Extension = "exe", - [Parameter(Mandatory = $false)] - $Install_Parameters = "/s", - [Parameter(Mandatory = $false)] - $URL = "https://dotnet.microsoft.com/en-us/download/dotnet/8.0", - [Parameter(Mandatory = $false)] - $htmlContent = (Invoke-WebRequest -UseBasicParsing $URL).Content, - [Parameter(Mandatory = $false)] - $VersionPattern = ']*?>(.*?)', - [Parameter(Mandatory = $false)] - $downloadLinkPattern = 'href="(/en-us/download/dotnet/thank-you/[^"]+?(\d+\.\d+\.\d+)([^"]+?))"' -) - -#Region Functions -Function Get-Online_Version { - $FilterContent = [regex]::Matches($htmlContent, $VersionPattern, 'Singleline') | Select-Object -ExpandProperty Value | Select-Object -First 15 - $SortContent = $FilterContent -replace '<[^>]+>' -replace '.NET' - $AppVersions = $SortContent | Where-Object { $_ -like "*$Version_Name*" } | Select-Object -First 1 - $Online_Version = $AppVersions -replace "[^\d*\.?\d*$/]" , '' - Return $Online_Version -} - -Function Get-Download_URL { - $regex = [regex]::new($downloadLinkPattern) # Create a Regex object - $match = $regex.Matches($htmlContent) | Select-Object -ExpandProperty Value | Where-Object { $_ -like "*Windows*" -and $_ -like "*x64*" -and $_ -like "*installer*" } | Select-Object -First 15 - $sort = $match -replace 'href="/' , "" -replace '"' , "" | Where-Object { $_ -like "*$Download_Name*" } | Select-Object -First 1 - $DownloadURL = (Invoke-WebRequest -UseBasicParsing "https://dotnet.microsoft.com/$sort").Links.href -like "*.exe" | Select-Object -First 1 - Return $DownloadURL -} - -Function Update-App { - #Get currently installed version - $B = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayName | Select-Object -First 1 - $Local_Version = $B -replace "(x64)" , '' -replace ".NET", '' -replace "[^\d*\.?\d*$/]" , '' - 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" - - #Comparing version already installed to what is online - If ([version]$Local_Version -lt [version]$Online_Version) { - Test-Probe_Online - Install-App - } - Else { Write-Host "$App_Name already on latest version (Installed version: $Local_Version)" } -} - -Function Install-ASP_NET_CORE { - $App_Name = "ASP.NET Core" - $Version_Name = "ASP Core Runtime" - $Download_Name = "aspnetcore" - $EPCache_Folder = "3rd Party Patches\$App_Name" - $Online_Version = Get-Online_Version - $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" - $DownloadURL = Get-Download_URL - Update-App -} - -Function Install-Desktop_Runtime { - $App_Name = "Desktop Runtime" - $Version_Name = "Desktop Runtime" - $Download_Name = "desktop" - $EPCache_Folder = "3rd Party Patches\$App_Name" - $Online_Version = Get-Online_Version - $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" - $DownloadURL = Get-Download_URL - Update-App -} - -Function Install-Net_Runtime { - $App_Name = ".NET Runtime" - $Version_Name = "Runtime [0-9]" - $Download_Name = "runtime-[0-9]" - $EPCache_Folder = "3rd Party Patches\$App_Name" - $Online_Version = Get-Online_Version - $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" - $DownloadURL = Get-Download_URL - Update-App -} - -Function Install-Net_SDK { - $App_Name = ".NET SDK" - $Version_Name = "SDK" - $Download_Name = "sdk" - $EPCache_Folder = "3rd Party Patches\$App_Name" - $Online_Version = Get-Online_Version - $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" - $DownloadURL = Get-Download_URL - Update-App -} - -#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 "*Windows Desktop Runtime*" -or $Applist.DisplayName -like "*.NET Runtime*" -or $Applist.DisplayName -like "*ASP.NET Core*" -or $Applist.DisplayName -like "*.NET SDK*") { - If ($Applist.DisplayName -like "*ASP.NET Core*") { Install-ASP_NET_CORE } - - If ($Applist.DisplayName -like "*Windows Desktop Runtime*") { Install-Desktop_Runtime } - - If ($Applist.DisplayName -like "*.NET Runtime*") { Install-Net_Runtime } - - If ($Applist.DisplayName -like "*.NET SDK*") { Install-Net_SDK } -} -Else { Write-Host "No .NET apps installed." } +<# +Author: Gabe Kerntke +Date: 07-14-2025 + +.Synopsis +Script to update .NET 8 + +.Modified +2025-07-14 (GabeK) - Original script created + +.PARAMETER VersionPattern + Regex pattern to grab all h3 headers on the $URL page + +.PARAMETER downloadLinkPattern + Regex pattern as a wildcard +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory = $false)] + $File_Name_Extension = "exe", + [Parameter(Mandatory = $false)] + $Install_Parameters = "/s", + [Parameter(Mandatory = $false)] + $URL = "https://dotnet.microsoft.com/en-us/download/dotnet/8.0", + [Parameter(Mandatory = $false)] + $htmlContent = (Invoke-WebRequest -UseBasicParsing $URL).Content, + [Parameter(Mandatory = $false)] + $VersionPattern = ']*?>(.*?)', + [Parameter(Mandatory = $false)] + $downloadLinkPattern = 'href="(/en-us/download/dotnet/thank-you/[^"]+?(\d+\.\d+\.\d+)([^"]+?))"' +) + +#Region Functions +Function Get-Online_Version { + $FilterContent = [regex]::Matches($htmlContent, $VersionPattern, 'Singleline') | Select-Object -ExpandProperty Value | Select-Object -First 15 + $SortContent = $FilterContent -replace '<[^>]+>' -replace '.NET' + $AppVersions = $SortContent | Where-Object { $_ -like "*$Version_Name*" } | Select-Object -First 1 + $Online_Version = $AppVersions -replace "[^\d*\.?\d*$/]" , '' + Return $Online_Version +} + +Function Get-Download_URL { + $regex = [regex]::new($downloadLinkPattern) # Create a Regex object + $match = $regex.Matches($htmlContent) | Select-Object -ExpandProperty Value | Where-Object { $_ -like "*Windows*" -and $_ -like "*x64*" -and $_ -like "*installer*" } | Select-Object -First 15 + $sort = $match -replace 'href="/' , "" -replace '"' , "" | Where-Object { $_ -like "*$Download_Name*" } | Select-Object -First 1 + $DownloadURL = (Invoke-WebRequest -UseBasicParsing "https://dotnet.microsoft.com/$sort").Links.href -like "*.exe" | Select-Object -First 1 + Return $DownloadURL +} + +Function Update-App { + #Get currently installed version + $B = Get-Software | Where-Object { $_.DisplayName -like "*$App_Name*" } | Select-Object -ExpandProperty DisplayName | Select-Object -First 1 + $Local_Version = $B -replace "(x64)" , '' -replace ".NET", '' -replace "[^\d*\.?\d*$/]" , '' + 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" + + #Comparing version already installed to what is online + If ([version]$Local_Version -lt [version]$Online_Version) { + Test-Probe_Online + Install-App + } + Else { Write-Host "$App_Name already on latest version (Installed version: $Local_Version)" } +} + +Function Install-ASP_NET_CORE { + $App_Name = "ASP.NET Core" + $Version_Name = "ASP Core Runtime" + $Download_Name = "aspnetcore" + $EPCache_Folder = "3rd Party Patches\$App_Name" + $Online_Version = Get-Online_Version + $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" + $DownloadURL = Get-Download_URL + Update-App +} + +Function Install-Desktop_Runtime { + $App_Name = "Desktop Runtime" + $Version_Name = "Desktop Runtime" + $Download_Name = "desktop" + $EPCache_Folder = "3rd Party Patches\$App_Name" + $Online_Version = Get-Online_Version + $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" + $DownloadURL = Get-Download_URL + Update-App +} + +Function Install-Net_Runtime { + $App_Name = ".NET Runtime" + $Version_Name = "Runtime [0-9]" + $Download_Name = "runtime-[0-9]" + $EPCache_Folder = "3rd Party Patches\$App_Name" + $Online_Version = Get-Online_Version + $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" + $DownloadURL = Get-Download_URL + Update-App +} + +Function Install-Net_SDK { + $App_Name = ".NET SDK" + $Version_Name = "SDK" + $Download_Name = "sdk" + $EPCache_Folder = "3rd Party Patches\$App_Name" + $Online_Version = Get-Online_Version + $File_Name = "$App_Name-$Online_Version.$File_Name_Extension" + $DownloadURL = Get-Download_URL + Update-App +} + +#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 "*Windows Desktop Runtime*" -or $Applist.DisplayName -like "*.NET Runtime*" -or $Applist.DisplayName -like "*ASP.NET Core*" -or $Applist.DisplayName -like "*.NET SDK*") { + If ($Applist.DisplayName -like "*ASP.NET Core*") { Install-ASP_NET_CORE } + + If ($Applist.DisplayName -like "*Windows Desktop Runtime*") { Install-Desktop_Runtime } + + If ($Applist.DisplayName -like "*.NET Runtime*") { Install-Net_Runtime } + + If ($Applist.DisplayName -like "*.NET SDK*") { Install-Net_SDK } +} +Else { Write-Host "No .NET apps installed." } #Region Script End \ No newline at end of file