first commit

This commit is contained in:
jack
2026-04-04 15:32:51 +08:00
commit a862314d94
34 changed files with 10253 additions and 0 deletions

46
清除Windows日志.ps1 Executable file
View File

@@ -0,0 +1,46 @@
# Clear Windows Event Logs - Run as Administrator
# Clears Application, System, Security, Setup, and other logs
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Need Administrator. Right-click -> Run as administrator." -ForegroundColor Red
exit 1
}
$mainLogs = @('Application', 'Security', 'System', 'Setup')
$cleared = @()
$failed = @()
Write-Host "Clearing Windows Event Logs..." -ForegroundColor Cyan
Write-Host ""
foreach ($log in $mainLogs) {
try {
Clear-EventLog -LogName $log -ErrorAction Stop
$cleared += $log
Write-Host " OK: $log" -ForegroundColor Green
} catch {
$failed += "$log : $($_.Exception.Message)"
Write-Host " FAIL: $log - $($_.Exception.Message)" -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "Clearing other logs via wevtutil..." -ForegroundColor Cyan
$allLogs = wevtutil el 2>$null
foreach ($log in $allLogs) {
if ($mainLogs -notcontains $log) {
$r = wevtutil cl $log 2>&1
if ($LASTEXITCODE -eq 0) {
$cleared += $log
Write-Host " OK: $log" -ForegroundColor Green
} else {
$failed += "$log : $r"
}
}
}
Write-Host ""
Write-Host "Done. Cleared: $($cleared.Count) logs." -ForegroundColor Green
if ($failed.Count -gt 0) {
Write-Host "Failed: $($failed.Count) logs (some may be protected)." -ForegroundColor Yellow
}