惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
GbyAI
GbyAI
WordPress大学
WordPress大学
NISL@THU
NISL@THU
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
F
Full Disclosure
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V
Visual Studio Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
V
V2EX
The Hacker News
The Hacker News
Scott Helme
Scott Helme
T
Troy Hunt's Blog
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
C
Cyber Attacks, Cyber Crime and Cyber Security
O
OpenAI News
月光博客
月光博客
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
IT之家
IT之家
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
T
Tenable Blog
Jina AI
Jina AI
T
Tor Project blog
The Cloudflare Blog
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
A
Arctic Wolf

博客园 - 南国之恋

系统技术栈 解决delphi7在win10上安装后无法正常使用的问题 查看分区表大小 系统表空间清理 postman调用deepseek webapi 将Nginx安装为windows服务,下载nssm 单词系列2 2025高考英语高频易错词汇分类速记 vs2019 本地源“C:\Program Files\DevExpress 22.2\Components\System\Components\Packages”不存在 - 南国之恋 mysql数据库定时事件 plsql查询oracle数据表时,将备注显示成列名 生成脚本 达梦数据库学习记录 oracle密码过期问题,用户锁定问题 Delphi 7 编译软件申请管理员权限 mysql odbc delphi连接问题 调用Exe程序并且出现界面 CreateProc(ProcessName:String) c# winform exe.config不能更新 frp(fast reverse proxy)是一款高性能的反向代理应用 GitHub上整理的一些工具 Kettle 中文名称叫水壶
windows服务器C盘空间清理,发现大文件,可用!AutoCleanC_DeepScan
南国之恋 · 2026-03-10 · via 博客园 - 南国之恋

# AutoCleanC_DeepScan.ps1
# Windows Server 2012 C盘清理 + 深层扫描增强版

$LogDir = "C:\CleanCDrive"
$LogFile = "$LogDir\CleanLog.txt"
$ReportFile = "$LogDir\SpaceReport.txt"

If (!(Test-Path $LogDir)) { New-Item -ItemType Directory -Path $LogDir }

$IISLogKeepDays = 30
$LargeFileThresholdMB = 300

Function Write-Log {
    Param ([string]$Message)
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $logEntry = "$timestamp - $Message"
    Add-Content -Path $LogFile -Value $logEntry
    Write-Host $logEntry
}

Function Write-Report {
    Param ([string]$Message)
    Add-Content -Path $ReportFile -Value $Message
}

Write-Log "=================== C盘清理与深层分析开始 ==================="

# --------------------------
# 清理操作
# --------------------------
Try { Remove-Item "$env:windir\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue; Write-Log "Windows 临时文件清理完成" } Catch { Write-Log "清理 Windows 临时文件失败: $_" }
Try { Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue; Write-Log "用户临时文件清理完成" } Catch { Write-Log "清理用户临时文件失败: $_" }
Try { RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255; Write-Log "IE缓存清理完成" } Catch { Write-Log "清理 IE缓存失败: $_" }
Try { Stop-Service wuauserv -Force; Remove-Item "$env:SystemRoot\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue; Start-Service wuauserv; Write-Log "Windows更新缓存清理完成" } Catch { Write-Log "清理 Windows更新缓存失败: $_" }
Try { Clear-RecycleBin -Force -ErrorAction SilentlyContinue; Write-Log "回收站清理完成" } Catch { Write-Log "清理回收站失败: $_" }

# 清理 IIS 日志
Try {
    $IISLogPath = "C:\inetpub\logs\LogFiles"
    If (Test-Path $IISLogPath) {
        $cutoffDate = (Get-Date).AddDays(-$IISLogKeepDays)
        Get-ChildItem -Path $IISLogPath -Recurse -File | Where-Object { $_.LastWriteTime -lt $cutoffDate } | ForEach-Object {
            Remove-Item $_.FullName -Force -ErrorAction SilentlyContinue
            Write-Log "删除 IIS日志: $($_.FullName)"
        }
        Write-Log "IIS日志清理完成(保留最近 $IISLogKeepDays 天)"
    } Else { Write-Log "未找到 IIS日志路径: $IISLogPath" }
} Catch { Write-Log "清理 IIS日志失败: $_" }

# --------------------------
# 深层扫描 C盘重要目录
# --------------------------
Write-Report "=================== C盘空间深层分析 ==================="
Write-Report "分析时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"

$drive = Get-PSDrive C
Write-Report "C盘总大小: $([math]::Round($drive.Used/1GB + $drive.Free/1GB,2)) GB"
Write-Report "已用空间: $([math]::Round($drive.Used/1GB,2)) GB"
Write-Report "可用空间: $([math]::Round($drive.Free/1GB,2)) GB"
Write-Report "`r`n"

# 定义需要扫描的重要目录
$scanDirs = @(
    "C:\Windows",
    "C:\ProgramData",
    "C:\Users",
    "C:\inetpub\logs\LogFiles"
)

# 遍历重要目录统计大小
foreach ($dir in $scanDirs) {
    Try {
        $size = (Get-ChildItem $dir -Recurse -File -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum
        Write-Report "$([math]::Round($size/1GB,2)) GB - $dir"
    } Catch {
        Write-Log "计算文件夹大小失败: $dir"
    }
}

# --------------------------
# 数据库目录占用报告(可选,InfluxDB / 其他数据库)
# --------------------------
$DBDirs = @("C:\Users\Administrator\.influxdbv2")
foreach ($db in $DBDirs) {
    if (Test-Path $db) {
        Try {
            $size = (Get-ChildItem $db -Recurse -File -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum
            Write-Report "$([math]::Round($size/1GB,2)) GB - 数据库目录: $db"
        } Catch {
            Write-Log "计算数据库目录大小失败: $db"
        }
    }
}

# --------------------------
# 扫描大文件(>300 MB)
# --------------------------
Write-Report "`r`nC盘大文件(>$LargeFileThresholdMB MB):"
foreach ($dir in $scanDirs + $DBDirs) {
    Try {
        Get-ChildItem $dir -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Length -gt ($LargeFileThresholdMB *1MB) } | Sort-Object Length -Descending | ForEach-Object {
            $sizeGB = [math]::Round($_.Length/1GB,2)
            Write-Report "$sizeGB GB - $($_.FullName)"
        }
    } Catch {
        Write-Log "扫描大文件失败: $dir"
    }
}

Write-Log "C盘清理与深层分析完成"
Write-Report "=================== 分析结束 ===================`r`n"