#Requires -RunAsAdministrator
$SoftwareDistro = "C:\Windows\SoftwareDistribution"
$SoftwareDistroOld = "C:\Windows\SoftwareDistribution.old"
$CatRoot2 = "C:\Windows\System32\Catroot2"
$CatRoot2Old = "C:\Windows\System32\Catroot2.old"
Write-Host "Stopping required services..."
Stop-Service -Name "Wuauserv"
Stop-Service -Name "CryptSvc"
Stop-Service -Name "Bits"
Stop-Service -Name "MsiServer"
Write-Host "Renaming directories..."
if(Test-Path -Path $SoftwareDistroOld) {
Remove-Item -Path $SoftwareDistroOld -Force -Recurse
}...