From 76e3b4bc220973dc4213dd745b6d073d0b2f0b10 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 21 Jan 2023 18:20:57 +0100 Subject: [PATCH] Last edit, Done! --- Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 | 13 +++++++------ Winget-AutoUpdate/functions/Get-IncludedApps.ps1 | 12 +++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 index ab24b34..ff6878a 100644 --- a/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-ExcludedApps.ps1 @@ -4,10 +4,12 @@ function Get-ExcludedApps { if ($GPOList) { - $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList\' - $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property + 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 - if ($ValueNames) { foreach ($ValueName in $ValueNames) { $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) [PSCustomObject]@{ @@ -15,10 +17,9 @@ function Get-ExcludedApps { 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 041101e..c4cb053 100644 --- a/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 +++ b/Winget-AutoUpdate/functions/Get-IncludedApps.ps1 @@ -4,10 +4,12 @@ function Get-IncludedApps { if ($GPOList) { - $Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList\' - $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property + if (Test-Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList") { - if ($ValueNames) { + $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]@{ @@ -16,9 +18,9 @@ function Get-IncludedApps { } } - return $AppIDs } - + return $AppIDs + } elseif (Test-Path "$WorkingDir\included_apps.txt") {