win-scripts/system/clean_system.ps1

75 lines
3.2 KiB
PowerShell
Raw Permalink Normal View History

2021-07-30 14:29:03 +02:00
Write-Host ""
Write-Host -ForegroundColor Green "Cleanup scoop packages"
Write-Host ""
scoop cleanup *
2021-12-05 16:12:47 +01:00
Write-Host ""
Write-Host -ForegroundColor Green "Cleanup scoop cache"
Write-Host ""
scoop cache rm *
2021-07-30 14:29:03 +02:00
Write-Host ""
Write-Host -ForegroundColor Green "Cleaning chocolatey packages"
Write-Host ""
2021-08-07 11:59:57 +02:00
sudo choco-cleaner
Write-Host ""
Write-host -ForegroundColor Green "Deleting Rouge folders"
Write-Host ""
Write-Host -ForegroundColor Yellow "Removing congig.msi"
if (test-path C:\Config.Msi) {sudo remove-item -Path C:\Config.Msi -force -recurse}
Write-Host -ForegroundColor Yellow "Removing intel"
if (test-path c:\Intel) {remove-item -Path c:\Intel -force -recurse}
Write-Host -ForegroundColor Yellow "Removing Perflogs"
if (test-path c:\PerfLogs) {remove-item -Path c:\PerfLogs -force -recurse}
Write-Host -ForegroundColor Yellow "Removing Hp software driver repository"
if (test-path c:\swsetup) {remove-item -Path c:\swsetup -force -recurse} # HP Software and Driver Repositry
Write-Host -ForegroundColor Yellow "Removing memory.dmp"
if (test-path $env:windir\memory.dmp) {remove-item $env:windir\memory.dmp -force}
Write-Host ""
Write-host -ForegroundColor Green "Deleting Windows Error Reporting files"
Write-Host ""
if (test-path C:\ProgramData\Microsoft\Windows\WER) {Get-ChildItem -Path C:\ProgramData\Microsoft\Windows\WER -Recurse | Remove-Item -force -recurse}
Write-Host ""
Write-host -ForegroundColor Green "Removing System and User Temp Files"
Write-Host ""
Write-Host -ForegroundColor Yellow "Removing prefetch"
Remove-Item -Path "$env:windir\Prefetch\*" -Force -Recurse
Write-Host -ForegroundColor Yellow "Removing local microsoft junk"
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\WER\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IECompatCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IECompatUaCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IEDownloadHistory\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\INetCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\INetCookies\*" -Force -Recurse
2022-02-26 10:33:50 +01:00
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Terminal Server Client\Cache\*" -Force -Recurse
2021-12-05 16:12:47 +01:00
Write-Host -ForegroundColor Yellow "Removing temp files"
2022-02-26 10:33:50 +01:00
sudo Remove-Item -Path "C:\Users\*\AppData\Local\Temp" -Force -Recurse
2021-12-05 16:12:47 +01:00
sudo Remove-Item -Path "$env:windir\Temp\*" -Force -Recurse
2021-08-07 11:59:57 +02:00
Write-Host ""
Write-Host -ForegroundColor Green "Checking Component store size"
Write-Host ""
sudo dism /Online /Cleanup-Image /AnalyzeComponentStore
Write-Host ""
while ($true) {
$yn = Read-Host "Wan't to cleaunup Component store?"
if ($yn -eq "y" -Or $yn -eq "Y") {
Write-Host -ForegroundColor Green "Cleaning up Component store"
sudo dism /online /Cleanup-Image /StartComponentCleanup
break
}
elseif ($yn -eq "n" -Or $yn -eq "N") {
Write-Host -ForegroundColor Green "Skipping cleanup of component store"
break
}
2021-12-05 16:12:47 +01:00
}