Skip to content

Instantly share code, notes, and snippets.

@LinkPhoenix
Created October 20, 2025 00:07
Show Gist options
  • Select an option

  • Save LinkPhoenix/5573eaec8c2345598a38a6b894960683 to your computer and use it in GitHub Desktop.

Select an option

Save LinkPhoenix/5573eaec8c2345598a38a6b894960683 to your computer and use it in GitHub Desktop.
PowerShell script to clean all AOMEI Backupper log files and free disk space.
<#
.SYNOPSIS
Clear all log files from AOMEI Backupper installation directories.
.DESCRIPTION
This script automatically detects the installed version of AOMEI Backupper
by reading registry entries and cleans up all existing log files from the
associated log directory. It helps free disk space and ensures that AOMEI
Backupper runs with a clean log state, especially useful after numerous
backup or sync operations.
.PARAMETER None
No parameters required. The script must be executed with Administrator privileges.
.EXAMPLE
.\Clear-AOMEIBackupperLogs.ps1
Detects the AOMEI Backupper installation and deletes all log files.
.NOTES
Created: 2025-10-20
Version: 1.0
#>
# Requires elevated privileges
#Requires -RunAsAdministrator
# Script configuration
$registryPath = "HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AOMEI Backupper"
$registryKey = "AOMEI Backupper"
$basePath = "C:\\Program Files (x86)\\AOMEI\\AOMEI Backupper"
# Function to write colored output
function Write-ColorOutput {
param(
[string]$Message,
[string]$Color = "White"
)
Write-Host $Message -ForegroundColor $Color
}
# Main execution
try {
Write-ColorOutput "`n========================================" "Cyan"
Write-ColorOutput " AOMEI Backupper Log Cleaner" "Cyan"
Write-ColorOutput "========================================`n" "Cyan"
# Check if registry key exists
if (Test-Path $registryPath) {
Write-ColorOutput "[✓] Registry key found" "Green"
# Retrieve version number
$version = Get-ItemProperty -Path $registryPath -Name $registryKey -ErrorAction Stop
$versionNumber = $version.$registryKey
if ([string]::IsNullOrEmpty($versionNumber)) {
Write-ColorOutput "[!] Version number not found in registry" "Yellow"
exit 1
}
Write-ColorOutput "[✓] Detected version: $versionNumber" "Green"
# Build log directory path
$logPath = Join-Path -Path $basePath -ChildPath "$versionNumber\\log"
Write-ColorOutput "[i] Log path: $logPath" "Cyan"
# Check if log directory exists
if (Test-Path $logPath) {
Write-ColorOutput "[✓] Log directory found" "Green"
# Get log files count before deletion
$logFiles = Get-ChildItem -Path $logPath -File -ErrorAction SilentlyContinue
$fileCount = $logFiles.Count
if ($fileCount -eq 0) {
Write-ColorOutput "[i] Log directory is already empty" "Yellow"
} else {
Write-ColorOutput "[i] Found $fileCount log file(s)" "Cyan"
# Calculate total size
$totalSize = ($logFiles | Measure-Object -Property Length -Sum).Sum
$sizeMB = [math]::Round($totalSize / 1MB, 2)
Write-ColorOutput "[i] Total size: $sizeMB MB" "Cyan"
# Delete log files
Write-ColorOutput "`n[→] Deleting log files..." "Yellow"
Remove-Item -Path "$logPath\\*" -Force -Recurse -ErrorAction Stop
Write-ColorOutput "[✓] Successfully cleared $fileCount log file(s)" "Green"
Write-ColorOutput "[✓] Freed $sizeMB MB of disk space" "Green"
}
} else {
Write-ColorOutput "[!] Log directory not found: $logPath" "Red"
Write-ColorOutput "[i] AOMEI Backupper may not be installed or path is incorrect" "Yellow"
exit 1
}
} else {
Write-ColorOutput "[!] Registry key not found" "Red"
Write-ColorOutput "[i] AOMEI Backupper may not be installed" "Yellow"
exit 1
}
Write-ColorOutput "`n[✓] Operation completed successfully`n" "Green"
} catch {
Write-ColorOutput "`n[✗] Error occurred: $($_.Exception.Message)" "Red"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment