major update to override Write-Output func

This commit is contained in:
2023-10-05 13:11:38 -04:00
parent 31a06a9206
commit bbb4884818
52 changed files with 377 additions and 378 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ $TARGET_DIR = "${Env:WinDir}\SoftwareDistribution"
$DEST_DIR = "${Env:WinDir}\SoftwareDistribution.old"
## Delete any existing folder from a previous execution of this script
LogMsg "Deleting ""${DEST_DIR}"""
Write-Output "Deleting ""${DEST_DIR}"""
Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue }
Catch { LogErr $_.Exception.Message }
@@ -14,7 +14,7 @@ Control-Service -Stop -Name BITS
Control-Service -Stop -Name wuauserv
## Rename the SoftwareDistribution folder, forcing Windows Update to recreate all metrics and redownload all updates
LogMsg "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}"""
Write-Output "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}"""
Try { Rename-Item -Path $TARGET_DIR -NewName $DEST_DIR -Force }
Catch { LogErr $_.Exception.Message }
@@ -25,11 +25,11 @@ Control-Service -Start -Name wuauserv
## Delete SoftwareDistribution.old from this execution of this script
## Comment this section out if you want to leave the renamed folder there for some reason,
## but keep in mind this folder can be very large and takes up a lot of space.
LogMsg "Deleting ""${DEST_DIR}"""
Write-Output "Deleting ""${DEST_DIR}"""
Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue }
Catch { LogErr $_.Exception.Message }
## Force the Windows Update client to check for new updates
LogMsg "Resetting WSUS authorization and starting update detection"
Write-Output "Resetting WSUS authorization and starting update detection"
Try { Start-Process "${Env:WinDir}\System32\wuauctl.exe" -ArgumentList "/resetauthorization /detectnow" }
Catch { LogErr $_.Exception.Message }