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

27 lines
994 B
PowerShell
Raw 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
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
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
}