Overview
Maintenance of the Windows Server Update Services (WSUS) is periodically required for optimal performance. This includes:
- Regular upkeep to prevent patch failures and timeouts (e.g., exit code 340).
- Troubleshooting when encountering errors such as:
Often, these issues are caused by the WSUS configuration or insufficient maintenance. Below are both basic and advanced steps to keep WSUS running smoothly.
Basic Maintenance Operations on WSUS
Check if there is sufficient disk space, CPU consumption, Memory leak, connectivity checks and usual IT concerns, and verify the WSUS specifications match our specifications in Hardware and Software Specifications
WSUS Server Cleanup (Manual Method)
To run the WSUS Cleanup Wizard manually:
- Open the WSUS Administration Console.
- Navigate to Options > Server Cleanup Wizard.
- Select all cleanup options and proceed through the wizard.
- Upon completion, review the summary for details on recovered disk space, then click Finish.
Recommended: Automating WSUS Cleanup
Step 1: Create the PowerShell Script
-
Open Notepad, paste the following script (covers all cleanup tasks):
-
Save the file with:
-
File Name:
WSUS-Cleanup.ps1
-
Save as type:
All Files (*.*)
-
Location:
C:\Scripts\WSUS-Cleanup.ps1
(Create the "Scripts" folder if it doesn't exist.)
Step 2: Set Up Windows Task Scheduler
- Open Task Scheduler (
taskschd.msc
). - Click Action > Create Basic Task:
-
Name:
WSUS Cleanup
- Click Next.
-
Name:
-
Trigger (recommended):
- Select Weekly or Daily (weekly is sufficient for most environments).
- Click Next.
-
Action:
- Select Start a Program.
- Click Next.
- Set the following values:
Field | Value |
---|---|
Program/script | powershell.exe |
Add arguments | -ExecutionPolicy Bypass -File "C:\Scripts\WSUS-Cleanup.ps1" |
Start in (optional) | C:\Scripts\ |
Click Next and then click Finish to save the task.
Step 3: Test Your Script
- Right-click your new task in Task Scheduler and select Run.
- Monitor briefly to confirm it completes successfully
Notes:
- If your WSUS server hasn’t been cleaned recently, the first run might take several minutes or even timeout.
- If it does timeout, run the task again manually a few times until it completes successfully.
Optional Advanced: Reindexing the database (relevant only for large WSUS deployments with performance issues)
The performance of large WSUS deployments will degrade over time if the WSUS database isn't maintained properly. The SQL script in this article can be run by SQL Server administrators to reindex and defragment WSUS databases. It shouldn't be used on WSUS 2.0 databases.
This script does basic maintenance tasks on SUSDB:
- Identifies indexes that are fragmented, and defragments them. For certain tables, a fill factor is set to improve insert performance.
- Updates potentially out-of-date table statistics.
Please download the following script to continue Maintenance Tasks on SUSDB.sql
1. Download and Start Microsoft SQL Server Management Studio and connect to the base instance where the WSUS database is running.
Note: If you are using the Windows internal database, you must install Microsoft SQL Server Management Studio on the WSUS server and use as server name : \\.\pipe\Microsoft##WID\tsql\query
using Windows authentication.
2. Right-click on SUSDB and click on New Query.
3. Paste the script into the query box and click on Execute.
Wait while the request is being processed. Once the query is executed, the result is displayed under the messages tab
Note: You can first check if indexes already exist before creating them.
Please download the following modified script Query-Maintenance-on-SUSDB.sql
Reduce the size of the base
Always from SSMS, right-click on the database SUSDB then go to Tasks -> Shrink 3 and click on Database.
Click OK to start the database reduction.
Once optimization is complete, the window closes automatically.
Comments
0 comments
Please sign in to leave a comment.