-
清理临时文件:
powershellCopy CodeRemove-Item -Path "$env:TEMP\*" -Force -Recurse Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Force -Recurse
-
清理回收站:
powershellCopy CodeClear-RecycleBin -Force
-
清理浏览器缓存(例如清理 Chrome 缓存):
powershellCopy CodeRemove-Item -Path "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache\*" -Force -Recurse
-
清理 Windows 更新临时文件:
powershellCopy CodeGet-WindowsUpdateLog | Remove-WindowsUpdateLog
-
清理 Windows 错误报告和日志文件:
powershellCopy CodeGet-WinEvent -LogName "Application", "System" | Where-Object { $_.TimeCreated -lt (Get-Date).AddDays(-30) } | Remove-WinEvent
-
优化系统启动项: 可以通过 PowerShell 管理注册表或启动文件夹来禁用或管理启动项,这需要一些谨慎操作。
-
清理远程桌面连接历史记录:
powershellCopy CodeClear-History -CommandLineType "RemoteDesktop"
-
清理 Powershell 历史记录:
powershellCopy CodeClear-History
-
清理系统日志文件:
powershellCopy CodeClear-EventLog -LogName "Application", "System"
-
清理 IIS 日志文件:
powershellCopy CodeGet-ChildItem -Path "C:\inetpub\logs\LogFiles" | Remove-Item -Force -Recurse
-
清理临时 IIS 文件:
powershellCopy CodeRemove-Item -Path "C:\Windows\Temp\*" -Force -Recurse
-
清理 Windows 更新缓存:
powershellCopy CodeClean-CMUpdatePackage
-
清理 Windows Defender 定义文件缓存:
powershellCopy CodeClear-MpThreatCatalog
-
清理 Windows 更新日志和临时文件:
powershellCopy CodeRemove-Item -Path "$env:LOCALAPPDATA\Temp\WindowsUpdateLogs\*" -Force -Recurse
-
清理 PowerShell 缓存:
powershellCopy CodeClear-Host
-
清理用户临时文件和配置:
powershellCopy CodeRemove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Force -Recurse Remove-Item -Path "$env:APPDATA\Microsoft\Windows\Recent\*" -Force -Recurse
-
清理 Windows 搜索索引:
powershellCopy CodeGet-WindowsSearchIndex | Reset-WindowsSearchIndex
-
清理 Windows 更新备份文件:
powershellCopy CodeDism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
-
清理旧的 Windows 安装文件:
powershellCopy CodeDism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
-
清理 Windows Event 日志文件:
powershellCopy CodeClear-EventLog -LogName "Application", "System"
-
清理 Windows Update 下载的临时文件:
powershellCopy CodeRemove-Item -Path "$env:SYSTEMROOT\SoftwareDistribution\Download\*" -Force -Recurse
-
清理 Windows 更新错误报告:
powershellCopy CodeRemove-Item -Path "$env:LOCALAPPDATA\Microsoft\Windows\Windows Error Reporting\*" -Force -Recurse
-
清理 PowerShell 临时文件:
powershellCopy CodeRemove-Item -Path "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\*" -Force -Recurse
-
清理 Windows 应用程序日志:
powershellCopy CodeGet-WinEvent -LogName "Application" | Remove-WinEvent
-
清理 Windows 防火墙日志:
powershellCopy CodeGet-NetFirewallProfile | Get-NetFirewallLog | Clear-NetFirewallLog
-
清理 Windows 系统日志:
powershellCopy CodeGet-WinEvent -LogName "System" | Remove-WinEvent
-
清理 Windows 运行时组件日志:
powershellCopy CodeGet-WinEvent -LogName "Runtime" | Remove-WinEvent
-
清理 Windows 应用程序故障诊断日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Diagnostics-Performance/Operational" | Remove-WinEvent
-
清理 IIS 日志(特定日期范围内):
powershellCopy CodeGet-ChildItem -Path "C:\inetpub\logs\LogFiles" -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item -Force
-
清理 Windows PowerShell 工作流和任务注册表日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Remove-WinEvent
-
清理 Windows 安全审计日志:
powershellCopy CodeGet-WinEvent -LogName "Security" | Remove-WinEvent
-
清理 Windows 组件事件日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-WinINet/Analytic" | Remove-WinEvent
-
清除临时文件:
powershellCopy CodeRemove-Item -Path "$env:TEMP\*" -Force -Recurse
-
清除 Windows 更新缓存:
powershellCopy CodeRemove-Item -Path "$env:SystemRoot\SoftwareDistribution\Download\*" -Force -Recurse
-
清除事件日志(需以管理员身份运行):
powershellCopy Codewevtutil el | ForEach-Object {wevtutil cl $_}
-
清除用户临时文件:
powershellCopy CodeRemove-Item -Path "$env:USERPROFILE\AppData\Local\Temp\*" -Force -Recurse
-
清除 Internet Explorer 缓存:
powershellCopy CodeClear-IECache
-
清除 Windows Store 缓存:
powershellCopy CodeGet-AppxPackage -AllUsers | Where-Object {$_.Name -like "*WindowsStore*"} | Remove-AppxPackage
-
清除 PowerShell 缓存:
powershellCopy CodeClear-History
-
清除内存:
powershellCopy CodeClear-Host
-
优化系统磁盘:
powershellCopy CodeOptimize-Volume -DriveLetter C -Defrag -Verbose
-
清理 Windows PowerShell Core 日志:
powershellCopy CodeGet-WinEvent -LogName "Windows PowerShell Core/Operational" | Remove-WinEvent
-
清理 Windows Defender 防病毒日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | Remove-WinEvent
-
清理 Hyper-V 虚拟机日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Hyper-V-Worker-Admin" | Remove-WinEvent
-
清理 Windows 搜索索引日志:
powershellCopy CodeGet-WinEvent -LogName "Windows Search/Operational" | Remove-WinEvent
-
清理 DNS 服务器日志:
powershellCopy CodeGet-WinEvent -LogName "DNS Server/Analytical" | Remove-WinEvent
-
清理 DHCP 服务器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DHCP Server Events/Admin" | Remove-WinEvent
-
清理 Windows 版本管理日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-WindowsUpdateClient/Operational" | Remove-WinEvent
-
清理 Windows 内核事件日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Kernel-EventTracing/Operational" | Remove-WinEvent
-
清理 Windows 远程桌面服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" | Remove-WinEvent
-
清理 Windows 存储空间直通日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-StorageSpaces-Driver/Operational" | Remove-WinEvent
-
清理 Windows 进程活动日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-ProcessExit/Operational" | Remove-WinEvent
-
清理 Windows 进程启动日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-ProcessCreation/Operational" | Remove-WinEvent
-
清理 Windows 网络共享日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Shell-Core/Operational" | Remove-WinEvent
-
清理 Windows 升级日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-WindowsUpdateClient/Operational" | Remove-WinEvent
-
清理 Windows 存储传输服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-StorDiag/Operational" | Remove-WinEvent
-
清理 Windows 连接性解析器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-ConnectivityAnalyzer/Operational" | Remove-WinEvent
-
清理 Windows 设备管理器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" | Remove-WinEvent
-
清理 Windows 打印服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" | Remove-WinEvent
-
清理 Windows 驱动程序框架服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DriverFrameworks-UserMode/Operational" | Remove-WinEvent
-
清理 Windows 存储日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Storage-ClassPnP/Operational" | Remove-WinEvent
-
清理 Windows 文件共享服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-SMBServer/Audit" | Remove-WinEvent
-
清理 Windows 安全审计日志:
powershellCopy CodeGet-WinEvent -LogName "Security/AuditSuccess", "Security/AuditFailure" | Remove-WinEvent
-
清理 Windows 系统事件通知服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Sens/Operational" | Remove-WinEvent
-
清理 Windows 远程注册表服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-RemoteRegistry/Operational" | Remove-WinEvent
-
清理 Windows 电源管理日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Power-Troubleshooter/Operational" | Remove-WinEvent
-
清理 Windows DHCP 客户端日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DHCP-Client/Operational" | Remove-WinEvent
-
清理 Windows 安全中心日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-SecurityCenter/Operational" | Remove-WinEvent
-
清理 Windows 虚拟化日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Hyper-V-Worker-Admin/Operational" | Remove-WinEvent
-
清理 Windows 虚拟磁盘服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-VirtualDiskService/Operational" | Remove-WinEvent
-
清理 Windows 网络连接管理器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-NetworkConnectionBroker/Operational" | Remove-WinEvent
-
清理 Windows 安全日志:
powershellCopy CodeGet-WinEvent -LogName "Security" | Remove-WinEvent
-
清理 Windows 自动更新日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-WindowsUpdateClient/Operational" | Remove-WinEvent
-
清理 Windows 远程桌面服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" | Remove-WinEvent
-
清理 Windows 应用程序组件日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-AppModel-State/Operational" | Remove-WinEvent
-
清理 Windows 组件服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Com/Operational" | Remove-WinEvent
-
清理 Windows 启动日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Kernel-Boot/Operational" | Remove-WinEvent
-
清理 Windows 容器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Containers/Operational" | Remove-WinEvent
-
清理 Windows 定时任务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TaskScheduler/Operational" | Remove-WinEvent
-
清理 Windows 设备健康状况日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DeviceHealth-Attestation/Operational" | Remove-WinEvent
-
清理 Windows 系统故障排除日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Diagnosis-DPS/Operational" | Remove-WinEvent
-
清理 Windows 文件共享服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-SMBServer/Operational" | Remove-WinEvent
-
清理 Windows 进程活动日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-ProcessCreation/Operational" | Remove-WinEvent
-
清理 Windows 任务栏通知区域日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Shell-Core/Operational" | Remove-WinEvent
-
清理 Windows 存储空间日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-StorageSpaces-Driver/Operational" | Remove-WinEvent
-
清理 Windows 证书服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-CertificateServices-Client-Lifecycle-System/Operational" | Remove-WinEvent
-
清理 Windows 移动设备管理日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Mobile-Broadband-Experience/Operational" | Remove-WinEvent
-
清理 Windows 系统恢复日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-SystemRestore/Operational" | Remove-WinEvent
-
清理 Windows 内核事件追踪日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Kernel-EventTracing/Operational" | Remove-WinEvent
-
清理 Windows 安全审计日志:
powershellCopy CodeGet-WinEvent -LogName "Security" | Remove-WinEvent
-
清理 Windows 应用程序错误日志:
powershellCopy CodeGet-WinEvent -LogName "Application" | Remove-WinEvent
-
清理 Windows 系统错误日志:
powershellCopy CodeGet-WinEvent -LogName "System" | Remove-WinEvent
-
清理 Windows PowerShell 日志:
powershellCopy CodeGet-WinEvent -LogName "Windows PowerShell" | Remove-WinEvent
-
清理 Windows DNS 审计日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DNS-Client/Operational" | Remove-WinEvent
-
清理 Windows DHCP 审计日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DHCP-Client/Operational" | Remove-WinEvent
-
清理 Windows 文件复制服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DfsSvc/Operational" | Remove-WinEvent
-
清理 Windows 转发事件跟踪日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-EventForwarding/Operational" | Remove-WinEvent
-
清理 Windows 远程桌面服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" | Remove-WinEvent
-
清理 Windows 文件服务器资源管理器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-SRMSVC/Operational" | Remove-WinEvent
-
清理 Windows 存储池日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-StorageSpaces-ManagementAgent/Operational" | Remove-WinEvent
-
清理 Windows 扫描管理器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-ScanManagement/Operational" | Remove-WinEvent
-
清理 Windows 分析引擎日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Resource-Exhaustion-Detector/Operational" | Remove-WinEvent
-
清理 Windows 网络连接日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TCP/IP/Operational" | Remove-WinEvent
-
清理 Windows 网络驱动程序日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-NDIS/Operational" | Remove-WinEvent
-
清理 Windows 文件保护日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Wininit/Operational" | Remove-WinEvent
-
-
清理 Windows 文件复制服务调试日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-DfsSvc/Debug" | Remove-WinEvent
-
清理 Windows 远程管理服务日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" | Remove-WinEvent
-
清理 Windows 容器日志:
powershellCopy CodeGet-WinEvent -LogName "Microsoft-Windows-Containers/Operational" | Remove-WinEvent
-
清理 Windows 集群日志:
```powershell Get-WinEvent -LogName "Microsoft-Windows-FailoverClustering/Operational" | Remove-WinEvent ```
- 清理 Windows 数据保护日志:
```powershell Get-WinEvent -LogName "Microsoft-Windows-DataProtection-Server/Operational" | Remove-WinEvent ```
- 清理 Windows 数据保护日志:
```powershell Get-WinEvent -LogName "Microsoft-Windows-DataProtection-Client/Operational" | Remove-WinEvent ```
- 清理 Windows 数据库引擎服务日志:
```powershell Get-WinEvent -LogName "Microsoft-Windows-SQLEngine/Operational" | Remove-WinEvent ```
-
标签:powershellCopy,Code,WinEvent,Get,Windows,清理,Remove,磁盘空间 From: https://www.cnblogs.com/suv789/p/18288074