# 主脚本参数

# 关闭防⽕墙
#Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\mpssvc" -Name "Start" -Value "4"
Set-Service -Name MpsSvc -StartupType Manual

Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Stop-Service -Name "AJRouter"
Set-Service -Name "AJRouter" -StartupType Disabled
Stop-Service -Name "DiagTrack"
Set-Service -Name "DiagTrack" -StartupType Disabled
Stop-Service -Name "DPS"
Set-Service -Name "DPS" -StartupType Disabled
Stop-Service -Name "WdiServiceHost"
Set-Service -Name "WdiServiceHost" -StartupType Disabled
Stop-Service -Name "WdiSystemHost"
Set-Service -Name "WdiSystemHost" -StartupType Disabled
Stop-Service -Name "Spooler"
Set-Service -Name "Spooler" -StartupType Disabled
Stop-Service -Name "SensorService"
Set-Service -Name "SensorService" -StartupType Disabled
Stop-Service -Name "SCardSvr"
Set-Service -Name "SCardSvr" -StartupType Disabled
Stop-Service -Name "SysMain"
Set-Service -Name "SysMain" -StartupType Disabled
Stop-Service -Name "WerSvc"
Set-Service -Name "WerSvc" -StartupType Disabled
Stop-Service -Name "WbioSrvc"
Set-Service -Name "WbioSrvc" -StartupType Disabled
Stop-Service -Name "WpnService"
Set-Service -Name "WpnService" -StartupType Disabled
Set-Service -Name "wuauserv" -StartupType Manual

#改为手动更新
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name AUOptions -Value 3


#清理IIS访问⽇志和临时⽂件
Remove-Item -Path "C:\inetpub\logs\LogFiles\*" -Force -Recurse
Remove-Item -Path "C:\inetpub\Temp\*" -Force -Recurse

#清理临时⽂件
Remove-Item -Path "$env:TEMP\*" -Force -Recurse
Remove-Item -Path "$env:LOCALAPPDATA\Temp\*" -Force -Recurse
Remove-Item -Path "C:\Windows\TEMP\*" -Force -Recurse


#清理Windows更新产⽣的临时⽂件和⽇志⽂件。
Stop-Service -Name "wuauserv"
Remove-Item -Path "C:\Windows\Logs\WindowsUpdate\*" -Force -Recurse
Remove-Item -Path "C:\Windows\SoftwareDistribution\Download\*" -Force -Recurse
Remove-Item -Path "C:\Windows\SoftwareDistribution\DataStore\*" -Force -Recurse
Start-Service -Name "wuauserv"

#清理回收站
Clear-RecycleBin -Force


#清理历史访问记录
Remove-Item -Path "$env:APPDATA\Microsoft\Windows\Recent\*" -Force -Recurse


#清理事件记录
Get-EventLog -LogName * | ForEach { Clear-EventLog $_.Log }

#清理Powershell执⾏记录和临时⽂件。
Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\*" -Force -Recurse
Remove-Item -Path "$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\*" -Force -Recurse