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

24 lines
959 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 {
#Get WAU Configurations
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
#Get WAU Policies
$WAUPolicies = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue
#If WAU Policies detected, apply settings
if ($($WAUPolicies.WAU_ActivateGPOManagement -eq 1)) {
#Replace loaded configurations by ones from Policies
2023-10-09 23:15:01 +00:00
$WAUPolicies.PSObject.Properties | ForEach-Object {
$WAUConfig.PSObject.Properties.add($_)
}
#Add tag to activate WAU-Policies scheduled task
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
2023-10-09 23:15:01 +00:00
}
return $WAUConfig
}