remove write in "get" function
parent
af65eb6392
commit
efbaa6d3e5
|
@ -10,10 +10,17 @@ Daily update settings from policies
|
|||
. "$PSScriptRoot\functions\Get-WAUConfig.ps1"
|
||||
. "$PSScriptRoot\functions\Add-Shortcut.ps1"
|
||||
|
||||
#Check if GPO Management is enabled
|
||||
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
|
||||
if ($ActivateGPOManagement -eq 1) {
|
||||
#Add (or update) 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
|
||||
}
|
||||
|
||||
#Get WAU settings
|
||||
$WAUConfig = Get-WAUConfig
|
||||
|
||||
#Check if GPO got applied from Get-WAUConfig
|
||||
#Check if GPO got applied from Get-WAUConfig (tag)
|
||||
if ($WAUConfig.WAU_RunGPOManagement -eq 1) {
|
||||
|
||||
#Log init
|
||||
|
|
|
@ -2,28 +2,23 @@
|
|||
|
||||
Function Get-WAUConfig {
|
||||
|
||||
#Check if GPO Management is enabled
|
||||
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
|
||||
|
||||
if ($ActivateGPOManagement -eq 1) {
|
||||
|
||||
#Add a 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
|
||||
|
||||
#Get all WAU Policies
|
||||
$WAUPolicies = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
#Get WAU Configurations from install config
|
||||
$WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
|
||||
|
||||
#Check if GPO Management is enabled
|
||||
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
|
||||
|
||||
#If GPO Management is enabled, replace settings
|
||||
if ($ActivateGPOManagement -eq 1) {
|
||||
|
||||
#Get all WAU Policies
|
||||
$WAUPolicies = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue
|
||||
|
||||
#Replace loaded configurations by ones from Policies
|
||||
$WAUPolicies.PSObject.Properties | ForEach-Object {
|
||||
$WAUConfig.PSObject.Properties.add($_)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#Return config
|
||||
|
|
Loading…
Reference in New Issue