remove write in "get" function

pull/418/head
romanitho 2023-10-12 14:00:10 +02:00
parent af65eb6392
commit efbaa6d3e5
2 changed files with 15 additions and 13 deletions

View File

@ -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

View File

@ -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