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] 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 } + }