# ------------------------------
# Beast Mode Laptop Maintenance
# ------------------------------
# Function to check power and set plan
function Set-PowerPlan {
$powerStatus = (Get-WmiObject -Class Win32_Battery).BatteryStatus
if ($powerStatus -eq $null -or $powerStatus -eq 1) {
Write-Host "🟡 On Battery: Setting Balanced Plan..."
powercfg /setactive SCHEME_BALANCED
} else {
Write-Host "🟢 Plugged In: Setting Best Performance Plan..."
powercfg /setactive SCHEME_MIN
}
}
# Function to clear temp files
function Clear-TempFiles {
Write-Host "🧹 Cleaning Temp Files..."
$tempPath = $env:TEMP
Get-ChildItem -Path $tempPath -Recurse -Force -ErrorAction SilentlyContinue |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
# Function to monitor system usage
function Monitor-System {
$cpu = Get-Counter '\Processor(_Total)\% Processor Time'
$cpuUsage = [math]::Round($[Link],2)
$mem = Get-CimInstance Win32_OperatingSystem
$totalMem = [math]::Round($[Link] / 1MB,2)
$freeMem = [math]::Round($[Link] / 1MB,2)
$usedMem = [math]::Round($totalMem - $freeMem,2)
$memUsagePercent = [math]::Round(($usedMem / $totalMem) * 100,2)
$disk = Get-Counter '\PhysicalDisk(_Total)\% Disk Time'
$diskUsage = [math]::Round($[Link],2)
Write-Host "🔥 CPU Usage: $cpuUsage %"
Write-Host "🔥 Memory Usage: $usedMem GB / $totalMem GB ($memUsagePercent %)"
Write-Host "🔥 Disk Usage: $diskUsage %"
# Alerts
if ($cpuUsage -gt 80) {
Write-Warning "⚠️ High CPU Usage: $cpuUsage %"
}
if ($memUsagePercent -gt 80) {
Write-Warning "⚠️ High RAM Usage: $memUsagePercent %"
}
if ($diskUsage -gt 80) {
Write-Warning "⚠️ High Disk Usage: $diskUsage %"
}
}
# Execute functions
Set-PowerPlan
Clear-TempFiles
Monitor-System
Write-Host "✅ Beast Mode Maintenance Complete."