diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 330a43a..7598b75 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -200,21 +200,21 @@ if (Test-Network) { if ($GPOList) { if ($UseWhiteList) { $WhiteApps = $toUpdate.GetUpperBound(0) - $toUpdate = $toUpdate.Data if ($null -eq $WhiteApps) { Write-Log "Critical: White List doesn't exist in GPO, exiting..." "Red" New-Item "$WorkingDir\logs\error.txt" -Value "White List doesn't exist in GPO!" -Force Exit 1 } + $toUpdate = $toUpdate.Data } else { $BlackApps = $toSkip.GetUpperBound(0) - $toSkip = $toSkip.Data if ($null -eq $BlackApps) { Write-Log "Critical: Black List doesn't exist in GPO, exiting..." "Red" New-Item "$WorkingDir\logs\error.txt" -Value "Black List doesn't exist in GPO!" -Force Exit 1 } + $toSkip = $toSkip.Data } } diff --git a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index 6e50833..ab24b34 100644 --- a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -7,15 +7,18 @@ function Get-ExcludedApps { $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList\' $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property - foreach ($ValueName in $ValueNames) { - $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) - [PSCustomObject]@{ - Value = $ValueName - Data = $AppIDs.Trim() + if ($ValueNames) { + foreach ($ValueName in $ValueNames) { + $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) + [PSCustomObject]@{ + Value = $ValueName + Data = $AppIDs.Trim() + } } - } - return $AppIDs + return $AppIDs + + } } elseif (Test-Path "$WorkingDir\excluded_apps.txt") { diff --git a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 index 3802ce0..041101e 100644 --- a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -6,17 +6,19 @@ function Get-IncludedApps { $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList\' $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property - - foreach ($ValueName in $ValueNames) { - $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) - [PSCustomObject]@{ - Value = $ValueName - Data = $AppIDs.Trim() + + if ($ValueNames) { + foreach ($ValueName in $ValueNames) { + $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) + [PSCustomObject]@{ + Value = $ValueName + Data = $AppIDs.Trim() + } } + + return $AppIDs } - - return $AppIDs - + } elseif (Test-Path "$WorkingDir\included_apps.txt") {