Small bits

pull/263/head
KnifMelti 2023-01-21 17:37:03 +01:00
parent de8f32b50e
commit 021170b72b
3 changed files with 23 additions and 18 deletions

View File

@ -200,21 +200,21 @@ if (Test-Network) {
if ($GPOList) { if ($GPOList) {
if ($UseWhiteList) { if ($UseWhiteList) {
$WhiteApps = $toUpdate.GetUpperBound(0) $WhiteApps = $toUpdate.GetUpperBound(0)
$toUpdate = $toUpdate.Data
if ($null -eq $WhiteApps) { if ($null -eq $WhiteApps) {
Write-Log "Critical: White List doesn't exist in GPO, exiting..." "Red" 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 New-Item "$WorkingDir\logs\error.txt" -Value "White List doesn't exist in GPO!" -Force
Exit 1 Exit 1
} }
$toUpdate = $toUpdate.Data
} }
else { else {
$BlackApps = $toSkip.GetUpperBound(0) $BlackApps = $toSkip.GetUpperBound(0)
$toSkip = $toSkip.Data
if ($null -eq $BlackApps) { if ($null -eq $BlackApps) {
Write-Log "Critical: Black List doesn't exist in GPO, exiting..." "Red" 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 New-Item "$WorkingDir\logs\error.txt" -Value "Black List doesn't exist in GPO!" -Force
Exit 1 Exit 1
} }
$toSkip = $toSkip.Data
} }
} }

View File

@ -7,6 +7,7 @@ function Get-ExcludedApps {
$Key = 'HKEY_LOCAL_MACHINE\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 $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\BlackList").Property
if ($ValueNames) {
foreach ($ValueName in $ValueNames) { foreach ($ValueName in $ValueNames) {
$AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false)
[PSCustomObject]@{ [PSCustomObject]@{
@ -18,6 +19,8 @@ function Get-ExcludedApps {
return $AppIDs return $AppIDs
} }
}
elseif (Test-Path "$WorkingDir\excluded_apps.txt") { elseif (Test-Path "$WorkingDir\excluded_apps.txt") {
return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 } return (Get-Content -Path "$WorkingDir\excluded_apps.txt").Trim() | Where-Object { $_.length -gt 0 }

View File

@ -7,6 +7,7 @@ function Get-IncludedApps {
$Key = 'HKEY_LOCAL_MACHINE\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 $ValueNames = (Get-Item -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate\WhiteList").Property
if ($ValueNames) {
foreach ($ValueName in $ValueNames) { foreach ($ValueName in $ValueNames) {
$AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false) $AppIDs = [Microsoft.Win32.Registry]::GetValue($Key, $ValueName, $false)
[PSCustomObject]@{ [PSCustomObject]@{
@ -16,6 +17,7 @@ function Get-IncludedApps {
} }
return $AppIDs return $AppIDs
}
} }
elseif (Test-Path "$WorkingDir\included_apps.txt") { elseif (Test-Path "$WorkingDir\included_apps.txt") {