#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
}
if(Test-Path -Path $CatRoot2Old) {
Remove-Item -Path $CatRoot2Old -Force -Recurse
}
Rename-Item -Path $SoftwareDistro -NewName $SoftwareDistroOld -Force
Rename-Item -Path $CatRoot2 -NewName $CatRoot2Old -Force
Write-Host "Starting required services..."
Start-Service -Name "Wuauserv"
Start-Service -Name "CryptSvc"
Start-Service -Name "Bits"
Start-Service -Name "MsiServer"
Start-Sleep -Seconds 5
Write-Host "Cleaing up renamed directories..."
if((Test-Path -Path $SoftwareDistro) -and (Test-Path -Path $CatRoot2)) {
Remove-Item -Path $SoftwareDistroOld -Force -Recurse
Remove-Item -Path $CatRoot2Old -Force -Recurse
}