major change to override Write-Error func
This commit is contained in:
@@ -7,7 +7,7 @@ $DEST_DIR = "${Env:WinDir}\SoftwareDistribution.old"
|
||||
## Delete any existing folder from a previous execution of this script
|
||||
Write-Output "Deleting ""${DEST_DIR}"""
|
||||
Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
|
||||
## Stop Background Intelligent Transfer Services and Windows Update
|
||||
Control-Service -Stop -Name BITS
|
||||
@@ -16,7 +16,7 @@ Control-Service -Stop -Name wuauserv
|
||||
## Rename the SoftwareDistribution folder, forcing Windows Update to recreate all metrics and redownload all updates
|
||||
Write-Output "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}"""
|
||||
Try { Rename-Item -Path $TARGET_DIR -NewName $DEST_DIR -Force }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
|
||||
## Start Windows Update and Background Intelligent Transfer Services
|
||||
Control-Service -Start -Name BITS
|
||||
@@ -27,9 +27,9 @@ Control-Service -Start -Name wuauserv
|
||||
## but keep in mind this folder can be very large and takes up a lot of space.
|
||||
Write-Output "Deleting ""${DEST_DIR}"""
|
||||
Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
|
||||
## Force the Windows Update client to check for new updates
|
||||
Write-Output "Resetting WSUS authorization and starting update detection"
|
||||
Try { Start-Process "${Env:WinDir}\System32\wuauctl.exe" -ArgumentList "/resetauthorization /detectnow" }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
Reference in New Issue
Block a user