31 lines
1.4 KiB
PowerShell
31 lines
1.4 KiB
PowerShell
# =====================================================================
|
|
# clean_windows_temp_v1.0_2026-06-10.ps1
|
|
# Verze: 1.0 | Datum: 2026-06-10
|
|
# Popis: Vyčistí C:\Windows\Temp a C:\Windows\SoftwareDistribution\Download
|
|
# (cache Windows Update). Vyžaduje spuštění JAKO SPRÁVCE.
|
|
# Zastaví službu Windows Update, smaže cache, službu znovu spustí.
|
|
# =====================================================================
|
|
#Requires -RunAsAdministrator
|
|
|
|
$before = (Get-PSDrive C).Free
|
|
|
|
Write-Host "Mažu C:\Windows\Temp ..."
|
|
Get-ChildItem 'C:\Windows\Temp' -Force -ErrorAction SilentlyContinue |
|
|
Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Zastavuji službu Windows Update ..."
|
|
Stop-Service wuauserv -Force -ErrorAction SilentlyContinue
|
|
Stop-Service bits -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Mažu C:\Windows\SoftwareDistribution\Download ..."
|
|
Get-ChildItem 'C:\Windows\SoftwareDistribution\Download' -Force -ErrorAction SilentlyContinue |
|
|
Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Spouštím služby zpět ..."
|
|
Start-Service bits -ErrorAction SilentlyContinue
|
|
Start-Service wuauserv -ErrorAction SilentlyContinue
|
|
|
|
$after = (Get-PSDrive C).Free
|
|
Write-Host ("Uvolněno: {0:N2} GB | Volno celkem: {1:N2} GB" -f (($after-$before)/1GB), ($after/1GB))
|
|
Read-Host "Hotovo - Enter pro zavření"
|