wingetautoupdate/Sources/Winget-AutoUpdate/functions/Get-WAUConfig.ps1

28 lines
1.1 KiB
PowerShell
Raw Permalink Normal View History

2023-10-09 23:15:01 +00:00
#Function to get the WAU settings, including Domain/Local Policies (GPO)
Function Get-WAUConfig {
2023-10-12 12:00:10 +00:00
#Get WAU Configurations from install config
2024-09-13 20:06:18 +00:00
$WAUConfig_64_86 = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate*", "HKLM:\SOFTWARE\WOW6432Node\Romanitho\Winget-AutoUpdate*" -ErrorAction SilentlyContinue | Sort-Object { $_.ProductVersion } -Descending
$WAUConfig = $WAUConfig_64_86[0]
2023-10-12 12:00:10 +00:00
2023-10-11 22:53:21 +00:00
#Check if GPO Management is enabled
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
2023-10-09 23:15:01 +00:00
2023-10-12 12:00:10 +00:00
#If GPO Management is enabled, replace settings
2023-10-11 22:53:21 +00:00
if ($ActivateGPOManagement -eq 1) {
2023-10-09 23:15:01 +00:00
2023-10-11 22:53:21 +00:00
#Get all WAU Policies
$WAUPolicies = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue
2023-10-09 23:15:01 +00:00
#Replace loaded configurations by ones from Policies
2023-10-09 23:15:01 +00:00
$WAUPolicies.PSObject.Properties | ForEach-Object {
$WAUConfig.PSObject.Properties.add($_)
}
2023-10-12 12:00:10 +00:00
2023-10-09 23:15:01 +00:00
}
2023-10-11 22:53:21 +00:00
#Return config
2023-10-09 23:15:01 +00:00
return $WAUConfig
2024-09-02 14:10:21 +00:00
}