From 328bf3e7561dc94f2f2b3ffc7e923454b64fede4 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 14 Jan 2023 03:07:34 +0100 Subject: [PATCH] GPO log only if changed or not --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 94f8124..a201e0d 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -23,9 +23,14 @@ if ($IsSystem) { #Get and set Domain/Local Policies (GPO) $ActivateGPOManagement, $ChangedSettings = Get-Policies - if ($null -ne $ChangedSettings -and $ActivateGPOManagement) { + if ($ActivateGPOManagement) { Write-Log "Activated WAU GPO Management detected, comparing..." - Write-Log "Changed settings: $ChangedSettings" "Yellow" + if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0) { + Write-Log "Changed settings detected and applied" "Yellow" + } + else { + Write-Log "No Changed settings detected" "Yellow" + } } # Maximum number of log files to keep. Default is 3. Setting MaxLogFiles to 0 will keep all log files. @@ -56,9 +61,14 @@ if ($IsSystem) { $Log = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################" $Log | out-file -filepath $LogFile -Append Write-Log "Running in System context" - if ($null -ne $ChangedSettings -and $ActivateGPOManagement) { + if ($ActivateGPOManagement) { Write-Log "Activated WAU GPO Management detected, comparing..." - Write-Log "Changed settings: $ChangedSettings" "Yellow" + if ($null -ne $ChangedSettings -and $ChangedSettings -ne 0) { + Write-Log "Changed settings detected and applied" "Yellow" + } + else { + Write-Log "No Changed settings detected" "Yellow" + } } Write-Log "Max Log Size reached: $MaxLogSize bytes - Rotated Logs" }