GPO log only if changed or not

pull/257/head
KnifMelti 2023-01-14 03:07:34 +01:00
parent 78a922a538
commit 328bf3e756
1 changed files with 14 additions and 4 deletions

View File

@ -23,9 +23,14 @@ if ($IsSystem) {
#Get and set Domain/Local Policies (GPO) #Get and set Domain/Local Policies (GPO)
$ActivateGPOManagement, $ChangedSettings = Get-Policies $ActivateGPOManagement, $ChangedSettings = Get-Policies
if ($null -ne $ChangedSettings -and $ActivateGPOManagement) { if ($ActivateGPOManagement) {
Write-Log "Activated WAU GPO Management detected, comparing..." 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. # 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 = "`n##################################################`n# CHECK FOR APP UPDATES - $(Get-Date -Format (Get-culture).DateTimeFormat.ShortDatePattern)`n##################################################"
$Log | out-file -filepath $LogFile -Append $Log | out-file -filepath $LogFile -Append
Write-Log "Running in System context" Write-Log "Running in System context"
if ($null -ne $ChangedSettings -and $ActivateGPOManagement) { if ($ActivateGPOManagement) {
Write-Log "Activated WAU GPO Management detected, comparing..." 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" Write-Log "Max Log Size reached: $MaxLogSize bytes - Rotated Logs"
} }