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