控制記錄檔達到其大小上限時的事件記錄檔行為 的登錄值 Retention (Security)電腦HKLM\Software\Policies\Microsoft\Windows\EventLog\Security

原則 ID
Channel_Log_Retention_2
適用範圍
電腦設定
支援的作業系統
至少需要 Windows Vista
來源
Administrative Templates (.admx) for Windows 11 2026 Update (26H2) (版本 1.0)
類別
Windows 元件 › 事件記錄服務 › 安全性

登錄

Retention

REG_SZ電腦
啟用時的值
1
停用時的值
0
以 .reg · CMD · PowerShell 套用
.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\EventLog\Security]

; 選項 (只使用其中一個)
; 已啟用
"Retention"="1"
; 已停用
"Retention"="0"
CMD
:: 選項 (只使用其中一個)

:: 已啟用
reg add "HKLM\Software\Policies\Microsoft\Windows\EventLog\Security" /v "Retention" /t REG_SZ /d 1 /f
:: 已停用
reg add "HKLM\Software\Policies\Microsoft\Windows\EventLog\Security" /v "Retention" /t REG_SZ /d 0 /f
PowerShell
# 共通: 建立機碼
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\EventLog\Security' -Force | Out-Null

# 選項 (只使用其中一個)
# 已啟用
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\EventLog\Security' -Name 'Retention' -PropertyType String -Value '1' -Force | Out-Null
# 已停用
New-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\EventLog\Security' -Name 'Retention' -PropertyType String -Value '0' -Force | Out-Null