small fixes
parent
83d5467e08
commit
c76afdacaf
|
@ -349,15 +349,18 @@ if (Test-Network) {
|
|||
}
|
||||
#if app is in "excluded list", skip it
|
||||
elseif ($toSkip.AppID -contains $app.Id) {
|
||||
if ($toSkip.PinnedVersion) {
|
||||
$regexPattern = $toSkip.PinnedVersion -replace '\.', '\.' -replace '\*', '.*'
|
||||
$regexPattern = "^$regexPattern$"
|
||||
$matchingToSkip = $toSkip | Where-Object { $_.AppID -contains $app.Id }
|
||||
if ($matchingToSkip.PinnedVersion) {
|
||||
$regexPattern = $matchingToSkip.PinnedVersion -replace '\.', '\.' -replace '\*', '.*'
|
||||
$regexPattern = "^$regexPattern$".Trim()
|
||||
if ($app.AvailableVersion -match $regexPattern) {
|
||||
Update-App $app
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-ToLog "$($app.Name) : Skipped upgrade because it is in the excluded app list" "Gray"
|
||||
}
|
||||
}
|
||||
#if app with wildcard is in "excluded list", skip it
|
||||
elseif ($toSkip.AppID | Where-Object { $app.Id -like $_ }) {
|
||||
Write-ToLog "$($app.Name) : Skipped upgrade because it is *wildcard* in the excluded app list" "Gray"
|
||||
|
|
|
@ -3,7 +3,7 @@ function Get-ExcludedApps {
|
|||
|
||||
$AppIDs = @()
|
||||
|
||||
#blacklist in registry
|
||||
# Blacklist in registry
|
||||
if ($GPOList) {
|
||||
Write-ToLog "-> Excluded apps from GPO is activated"
|
||||
if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") {
|
||||
|
@ -17,7 +17,7 @@ function Get-ExcludedApps {
|
|||
Write-ToLog "-> Successfully loaded excluded apps list."
|
||||
}
|
||||
}
|
||||
#blacklist pulled from URI
|
||||
# Blacklist pulled from URI
|
||||
elseif ($URIList) {
|
||||
$RegPath = "$WAU_GPORoot";
|
||||
$RegValueName = 'WAU_URIList';
|
||||
|
@ -41,7 +41,7 @@ function Get-ExcludedApps {
|
|||
}
|
||||
}
|
||||
}
|
||||
#blacklist pulled from local file
|
||||
# Blacklist pulled from local file
|
||||
elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
|
||||
$AppIDs = (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | ForEach-Object {
|
||||
[PSCustomObject]@{
|
||||
|
@ -51,7 +51,7 @@ function Get-ExcludedApps {
|
|||
}
|
||||
Write-ToLog "-> Successfully loaded local excluded apps list."
|
||||
}
|
||||
#blacklist pulled from default file
|
||||
# Blacklist pulled from default file
|
||||
elseif (Test-Path "$WorkingDir\config\default_excluded_apps.txt") {
|
||||
$AppIDs = (Get-Content -Path "$WorkingDir\config\default_excluded_apps.txt").Trim() | ForEach-Object {
|
||||
[PSCustomObject]@{
|
||||
|
@ -64,11 +64,12 @@ function Get-ExcludedApps {
|
|||
|
||||
$WAUExcludePinnedApps = $WAUConfig.WAU_ExcludePinnedApps
|
||||
if ($WAUExcludePinnedApps -eq 1) {
|
||||
#blacklist pinned winget apps
|
||||
$pinnedAppsResult = & winget pin list | Where-Object { $_ -notlike " *" } | Out-String
|
||||
# Blacklist pinned winget apps
|
||||
$pinnedAppsResult = & $Winget pin list | Where-Object { $_ -notlike " *" } | Out-String
|
||||
if (!($pinnedAppsResult -match "-----")) {
|
||||
Write-ToLog "-> No pinned winget apps found, nothing to exclude."
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
# Split winget output to lines
|
||||
$lines = $pinnedAppsResult.Split([Environment]::NewLine) | Where-Object { $_ }
|
||||
|
||||
|
@ -90,24 +91,35 @@ function Get-ExcludedApps {
|
|||
$versionStart = $lines[$fl].IndexOf($index[2])
|
||||
$containsGating = $lines | Where-Object { $_.Trim() -like "*Gating*" }
|
||||
if ($containsGating) {
|
||||
$pinnedAppVersionStart = $lines[$fl].IndexOf($index[5])
|
||||
$pinnedAppVersionStart = $lines[$fl].IndexOf($index[4])
|
||||
}
|
||||
|
||||
# Now cycle through the real package lines and split accordingly
|
||||
For ($i = $fl + 2; $i -lt $lines.Length; $i++) {
|
||||
$line = $lines[$i] -replace "[\u2026]|", " " # Fix "..." in long names
|
||||
$line = $lines[$i] -replace "[\u2026]", " " # Fix ellipsis in long names
|
||||
if (-Not ($line.StartsWith("-----"))) {
|
||||
|
||||
# (Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications
|
||||
if ($line -match "\w\.\w") {
|
||||
$softwareId = $line.Substring($idStart, $versionStart - $idStart).TrimEnd()
|
||||
|
||||
if ($line -like "*Gating*") {
|
||||
# Ensure start index is within bounds
|
||||
if ($pinnedAppVersionStart -lt $line.Length) {
|
||||
$pinnedVersion = $line.Substring($pinnedAppVersionStart).TrimStart() # Get the pinned version
|
||||
$pinnedVersion = $pinnedVersion -replace "^Gating\s+", ""
|
||||
$AdditionalLogText = "with version $pinnedVersion"
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-ToLog "Cannot extract pinned app version; invalid start index"
|
||||
$pinnedVersion = $null
|
||||
}
|
||||
}
|
||||
else {
|
||||
$pinnedVersion = $null
|
||||
$AdditionalLogText = $null
|
||||
}
|
||||
|
||||
if ($null -ne $softwareId) {
|
||||
# Add the extracted software ID and version to the list
|
||||
$AppIDs += [PSCustomObject]@{
|
||||
|
|
Loading…
Reference in New Issue