From 608c0e95ca9e1787435df15338636dc47ffb9457 Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:39:37 +0000 Subject: [PATCH 1/6] Update Get-ExcludedApps.ps1 Fix Get-ExcludedApps where GPO is in use to properly generate the array --- .../Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index 0212e5c..610b0d1 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -10,16 +10,14 @@ function Get-ExcludedApps { $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property + $AppIDs = @() + foreach ($ValueName in $ValueNames) { - $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) - [PSCustomObject]@{ - Value = $ValueName - Data = $AppIDs.Trim() - } + $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName) } } - return $AppIDs + return $AppIDs | Where-Object { $_.length -gt 0 } } elseif (Test-Path "$WorkingDir\excluded_apps.txt") { From 7bbc406706c96e20a7d78f0e7122a622153782a5 Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:40:10 +0000 Subject: [PATCH 2/6] Update Get-IncludedApps.ps1 Updated Get-IncludedApps to work correctly with GPO source. --- .../WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index ae2a8ad..14d8aee 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -10,12 +10,10 @@ function Get-IncludedApps { $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property + $AppIDs = @() + foreach ($ValueName in $ValueNames) { - $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) - [PSCustomObject]@{ - Value = $ValueName - Data = $AppIDs.Trim() - } + $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList" -Name $ValueName) } } From 6a8215e39c58df25131c9a41e08c29ede1ee9eb6 Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:55:06 +0000 Subject: [PATCH 3/6] remove .data from the main upgrade add log for excluded / included apps --- Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 index 545049a..d5702b9 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -245,7 +245,8 @@ if (Test-Network) { New-Item "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force Exit 1 } - $toUpdate = $toUpdate.Data + $toUpdate = $toUpdate + foreach ($app in $toUpdate) { Write-ToLog "Include app ${app}" } } else { $BlackList = $toSkip.GetUpperBound(0) @@ -254,7 +255,8 @@ if (Test-Network) { New-Item "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force Exit 1 } - $toSkip = $toSkip.Data + $toSkip = $toSkip + foreach ($app in $toSkip) { Write-ToLog "Exclude app ${app}" } } } From e265146a0beabc038735cfce546b25016749d5f0 Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:01:29 +0000 Subject: [PATCH 4/6] Add trim back to the block/whitelist generator --- Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 | 2 +- Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index 610b0d1..8a949f9 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -13,7 +13,7 @@ function Get-ExcludedApps { $AppIDs = @() foreach ($ValueName in $ValueNames) { - $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName) + $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim() } } diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index 14d8aee..549bc8f 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -13,7 +13,7 @@ function Get-IncludedApps { $AppIDs = @() foreach ($ValueName in $ValueNames) { - $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList" -Name $ValueName) + $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList" -Name $ValueName).Trim() } } From 85f5c2aab407551ca1205f310d869ef96837b48c Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:48:12 +0000 Subject: [PATCH 5/6] removed unncessary assignment --- Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 index d5702b9..879516f 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -245,7 +245,6 @@ if (Test-Network) { New-Item "$WorkingDir\logs\error.txt" -Value "Whitelist doesn't exist in GPO" -Force Exit 1 } - $toUpdate = $toUpdate foreach ($app in $toUpdate) { Write-ToLog "Include app ${app}" } } else { @@ -255,7 +254,6 @@ if (Test-Network) { New-Item "$WorkingDir\logs\error.txt" -Value "Blacklist doesn't exist in GPO" -Force Exit 1 } - $toSkip = $toSkip foreach ($app in $toSkip) { Write-ToLog "Exclude app ${app}" } } } From a8bfbe6ab964c01628a2ee31fe79fe2de2d65275 Mon Sep 17 00:00:00 2001 From: Nick Brown <109540830+nickjisc@users.noreply.github.com> Date: Fri, 15 Mar 2024 09:39:51 +0000 Subject: [PATCH 6/6] Added the uri fething from #586 --- .../functions/Get-ExcludedApps.ps1 | 33 +++++++++++++++---- .../functions/Get-IncludedApps.ps1 | 33 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index 8a949f9..ce5811e 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -2,28 +2,49 @@ function Get-ExcludedApps { + $AppIDs = @() + + #region blacklist in registry if ($GPOList) { if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList") { - - $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList\' - $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property - $AppIDs = @() - foreach ($ValueName in $ValueNames) { $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList" -Name $ValueName).Trim() } } - return $AppIDs | Where-Object { $_.length -gt 0 } + + } + #endregion blacklist in registry + #region blacklist pulled from URI + elseif ($URIList) { + + $RegPath = "$WAU_GPORoot"; + $RegValueName = 'WAU_URIList'; + + if (Test-Path -Path $RegPath) { + $RegKey = Get-Item -Path $RegPath; + $WAUURI = $RegKey.GetValue($RegValueName); + if ($null -ne $WAUURI) { + $resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials; + if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) { + $resp.Content.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) | + ForEach-Object { + $AppIds += $_ + } + } + } + } } + #endregion blacklist pulled from URI elseif (Test-Path "$WorkingDir\excluded_apps.txt") { return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } } + return $AppIDs | Where-Object { $_.length -gt 0 } } diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index 549bc8f..950cede 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -1,29 +1,50 @@ #Function to get the allow List apps function Get-IncludedApps { + $AppIDs = @() + #region whitelist in registry if ($GPOList) { if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList") { - - $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList\' - $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property - $AppIDs = @() - foreach ($ValueName in $ValueNames) { $AppIDs += (Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList" -Name $ValueName).Trim() } } - return $AppIDs + + } + #endregion whitelist in registry + #region whitelist pulled from URI + elseif ($URIList) { + + $RegPath = "$WAU_GPORoot"; + $RegValueName = 'WAU_URIList'; + + if (Test-Path -Path $RegPath) { + $RegKey = Get-Item -Path $RegPath; + $WAUURI = $RegKey.GetValue($RegValueName); + if ($null -ne $WAUURI) { + $resp = Invoke-WebRequest -Uri $WAUURI -UseDefaultCredentials; + if ($resp.BaseResponse.StatusCode -eq [System.Net.HttpStatusCode]::OK) { + $resp.Content.Split([System.Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries) | + ForEach-Object { + $AppIds += $_ + } + } + } + } } + #endregion whitelist pulled from URI elseif (Test-Path "$WorkingDir\included_apps.txt") { return (Get-Content -Path "$WorkingDir\included_apps.txt").Trim() | Where-Object { $_.length -gt 0 } } + return $AppIDs | Where-Object { $_.length -gt 0 } + }