Skip to content

Commit ab4ea12

Browse files
Update README.md
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <[email protected]>
1 parent 67589c9 commit ab4ea12

1 file changed

Lines changed: 139 additions & 84 deletions

File tree

  • SysAdmin-Tools/WSUS-Management-Tools
Lines changed: 139 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,207 @@
11
# ⚙️ WSUS Management Tools
22

33
## 📝 Overview
4-
The **WSUS Management Tools** repository provides a curated set of **PowerShell scripts** to automate, maintain, and optimize **Windows Server Update Services (WSUS)** and its **SUSDB (Windows Internal Database)**.
5-
These tools are designed for **Active Directory** and **standalone** environments, with a lightweight **GUI** for administrators.
4+
5+
The **WSUS Management Tools** suite provides a comprehensive and enterprise-grade set of **PowerShell tools** for maintaining, auditing, and optimizing **Windows Server Update Services (WSUS)** and its **SUSDB (Windows Internal Database)**.
6+
7+
These tools are aligned with the same **design, logging, GUI, and execution standards** used across the *Windows‑SysAdmin‑ProSuite*, supporting both **standalone WSUS servers** and **Active Directory–integrated environments**.
8+
9+
They are built to reduce operational risk, improve database performance, and provide **auditable, repeatable WSUS maintenance workflows**.
610

711
---
812

913
## ✅ Key Features
10-
- **Graphical Interface**: Run maintenance tasks via GUI (no command line required)
11-
- **Index Optimization**: Reports fragmentation and executes **smart reindex logic** for SUSDB
12-
- **Assembly Detection**: Validates and loads WSUS Admin assemblies from the GAC or known paths
13-
- **Centralized Logging**: `.log` and `.csv` outputs with structured, timestamped entries
14-
- **Progress Tracker**: Real progress bar bounded at 100%, with weighted phases (declines, cleanup, DB tasks)
15-
- **Modular Design**: Scripts can run standalone or be scheduled with Task Scheduler/GPO
1614

17-
---
15+
- 🖥️ **GUI‑Driven Maintenance**
16+
Perform complex WSUS tasks without command-line interaction
1817

19-
## 🛠️ Prerequisites
18+
- 🗄️ **SUSDB Health & Performance**
19+
- Fragmentation analysis
20+
- Smart index reorganization vs rebuild
21+
- Statistics update and integrity checks
2022

21-
1. **PowerShell**
22-
- Requires **Windows PowerShell 5.1+**
23-
```powershell
24-
$PSVersionTable.PSVersion
25-
````
23+
- 🧩 **WSUS Assembly Validation**
24+
- Automatic detection and loading of `Microsoft.UpdateServices.Administration.dll`
25+
- Clear guidance when WSUS Admin components are missing
2626

27-
2. **Administrator Privileges**
27+
- 📊 **Structured Logging & Reporting**
28+
- `.log` (execution trace)
29+
- `.csv` (decline counts, cleanup metrics)
30+
- Timestamped, session‑scoped outputs
2831

29-
* Must be run **elevated** to access WSUS APIs and SUSDB
32+
- 📈 **Weighted Progress Tracking**
33+
- Real progress bar capped at 100%
34+
- Phased execution (decline → cleanup → database)
3035

31-
3. **Required Modules**
36+
- 🧱 **Enterprise‑Ready Design**
37+
- Modular scripts
38+
- GUI + non‑interactive execution
39+
- Safe for Task Scheduler and GPO execution
3240

33-
* `UpdateServices` (included with the WSUS Administration Console / Tools)
34-
* `ActiveDirectory` *(optional, for WSUS server discovery)*
41+
---
3542

36-
4. **SQLCMD Tools**
43+
## 🛠️ Prerequisites
3744

38-
* Required to execute SQL scripts on SUSDB (via named pipe: `np:\\.\pipe\MICROSOFT##WID\tsql\query`)
39-
* Ensure **`sqlcmd.exe`** is installed and on your `PATH`
45+
### 1. ⚙️ PowerShell
46+
- Windows PowerShell **5.1 or later**
47+
```powershell
48+
$PSVersionTable.PSVersion
49+
```
4050

41-
5. **Execution Policy**
51+
### 2. 🔑 Administrator Privileges
52+
- Must be executed **elevated**
53+
- Required for WSUS API access and SUSDB maintenance
4254

43-
```powershell
44-
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
45-
```
55+
### 3. 📦 Required Components
4656

47-
6. **SQL Script Files** (must exist in `C:\Logs-TEMP\WSUS-GUI\Scripts`)
57+
- **WSUS Administration Console**
58+
- Provides `UpdateServices` module
59+
- Installs WSUS Admin assemblies
4860

49-
* `wsus-verify-fragmentation.sql` → Reports index fragmentation (CHECK/VERIFY step)
50-
* `wsus-reindex-smart.sql` → Smart reindex logic (REORGANIZE vs REBUILD + UPDATE STATISTICS)
61+
- **PowerShell Modules**
62+
- `UpdateServices`
63+
- `ActiveDirectory` *(optional, for WSUS discovery)*
64+
65+
### 4. 🗄️ SQLCMD Utilities
66+
- Required to execute maintenance queries on WID / SUSDB
67+
- Named pipe:
68+
```
69+
np:\\.\pipe\MICROSOFT##WID\tsql\query
70+
```
71+
- Ensure `sqlcmd.exe` is installed and available in `PATH`
72+
73+
### 5. 🔧 Execution Policy
74+
```powershell
75+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
76+
```
77+
78+
### 6. 📄 Required SQL Scripts
79+
Location:
80+
```
81+
C:\Logs-TEMP\WSUS-GUI\Scripts\
82+
```
5183

52-
7. **WSUS Admin Assembly**
84+
- `wsus-verify-fragmentation.sql`
85+
- `wsus-reindex-smart.sql`
5386

54-
* Ensure `Microsoft.UpdateServices.Administration.dll` is available in the **GAC**
55-
* Validate with **Check-WSUS-AdminAssembly.ps1**
87+
### 7. 📦 WSUS Admin Assembly
88+
- `Microsoft.UpdateServices.Administration.dll`
89+
- Automatically validated by:
90+
- `Check-WSUS-AdminAssembly.ps1`
5691

5792
---
5893

5994
## 📜 Script Descriptions
6095

61-
| Script | Function |
62-
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
63-
| **Check-WSUS-AdminAssembly.ps1** | Detects/loads `Microsoft.UpdateServices.Administration.dll`; guides installation if missing |
64-
| **Generate-WSUSReindexScript.ps1** | Prompts thresholds and generates `wsus-reindex-smart.sql` for SUSDB index maintenance |
65-
| **Maintenance-WSUS-Admin-Tool.ps1** | GUI: decline updates (expired, superseded, unapproved), cleanup obsolete files/computers, SUSDB tasks (CHECKDB, shrink, reindex, backup) |
96+
| Script | Purpose |
97+
|------|--------|
98+
| **Check-WSUS-AdminAssembly.ps1** | Detects and loads WSUS Admin assemblies, validates WSUS tooling |
99+
| **Generate-WSUSReindexScript.ps1** | Generates adaptive reindex T‑SQL based on fragmentation thresholds |
100+
| **Maintenance-WSUS-Admin-Tool.ps1** | Full GUI‑based WSUS maintenance: decline, cleanup, SUSDB optimization |
66101

67102
---
68103

69104
## 🚀 Usage
70105

71-
### GUI Tool
106+
### 🖥️ WSUS Maintenance GUI
72107

73-
1. Right-click **Maintenance-WSUS-Admin-Tool.ps1****Run with PowerShell (Admin)**
74-
2. Configure WSUS server (defaults to **local FQDN** and port `8530` if missing)
75-
3. Select maintenance tasks (check boxes)
76-
4. Run and monitor execution in the status window, progress bar, and logs
108+
1. Right‑click **Maintenance-WSUS-Admin-Tool.ps1**
109+
2. Select **Run with PowerShell (Administrator)**
110+
3. Confirm WSUS server and port (default: local FQDN / `8530`)
111+
4. Select tasks:
112+
- Decline superseded / expired / unapproved updates
113+
- Cleanup obsolete computers and content
114+
- SUSDB integrity and performance tasks
115+
5. Monitor:
116+
- Status pane
117+
- Progress bar
118+
- Log file
77119

78-
### Index Reindex Script
120+
---
79121

80-
Generate a smart T-SQL script:
122+
### 🗄️ Generate Smart Reindex Script
81123

82124
```powershell
83125
.\Generate-WSUSReindexScript.ps1
84126
```
85127

86-
The script creates `wsus-reindex-smart.sql` with logic to reorganize or rebuild indexes based on thresholds.
128+
Automatically creates a **threshold‑based** reindex script:
129+
- REORGANIZE for medium fragmentation
130+
- REBUILD for high fragmentation
131+
- STATISTICS update included
87132

88-
### Assembly Validation
133+
---
89134

90-
Check if the WSUS Administration assembly is installed and loadable:
135+
### 🧩 Validate WSUS Assemblies
91136

92137
```powershell
93138
.\Check-WSUS-AdminAssembly.ps1
94139
```
95140

96-
---
97-
98-
## 📁 Complementary Files
141+
Validates WSUS Admin installation and prevents runtime failures.
99142

100-
* `wsus-verify-fragmentation.sql`
101-
**Reports fragmentation** levels per index in SUSDB. Use this to decide whether reindexing is required.
143+
---
102144

103-
* `wsus-reindex-smart.sql`
104-
**Executes smart reindexing**: skips low-page indexes, reorganizes medium fragmentation, rebuilds high fragmentation, updates statistics.
145+
## 📁 Supporting Files & Structure
105146

106-
* `settings.json`
107-
→ GUI persistence file created at first run of `Maintenance-WSUS-Admin-Tool.ps1`
147+
```
148+
C:\Logs-TEMP\WSUS-GUI\
149+
├── Scripts\
150+
├── Logs\
151+
├── CSV\
152+
├── Backups\
153+
└── settings.json
154+
```
108155

109-
* `Logs\`
110-
→ Example: `Maintenance-WSUS-Admin-Tool-20250915-095431.log`
156+
- **Scripts** → SQL & helper files
157+
- **Logs** → Execution traces
158+
- **CSV** → Decline / cleanup metrics
159+
- **Backups** → SUSDB safety exports
160+
- **settings.json** → GUI persistence
111161

112162
---
113163

114-
## 💡 Tips
115-
116-
* **Logs & Configs**
164+
## 💡 Operational Best Practices
117165

118-
* Scripts: `C:\Logs-TEMP\WSUS-GUI\Scripts\`
119-
* Logs: `C:\Logs-TEMP\WSUS-GUI\Logs\`
120-
* CSV: `C:\Logs-TEMP\WSUS-GUI\CSV\`
121-
* Backups: `C:\Logs-TEMP\WSUS-GUI\Backups\`
122-
* Settings: `C:\Logs-TEMP\WSUS-GUI\settings.json`
166+
-**Schedule Maintenance**
167+
- Run overnight using Task Scheduler or GPO
123168

124-
* **Console Visibility**
169+
- 🔐 **Least Privilege**
170+
- Use a dedicated WSUS admin account
125171

126-
* GUI hides the console window by default
127-
* Comment out the *Hide Console* block in scripts while debugging
172+
- 📁 **Centralize Logs**
173+
- Redirect `$LogDir` to a UNC share
128174

129-
* **Timeout Handling**
130-
131-
* Some WSUS builds lack `DatabaseCommandTimeout`; this is logged as `[DEBUG]`
132-
* **CompressUpdates** may time out — run standalone during off-hours if needed
175+
- 🧪 **Test First**
176+
- Run CHECK / VERIFY before REBUILD operations
133177

134178
---
135179

136180
## 🧰 Troubleshooting
137181

138-
* **`sqlcmd.exe` not found** → Install SQL Server Command Line Utilities and add to PATH
139-
* **`Get-WsusServer failed`** → Ensure WSUS Admin Console is installed and run PowerShell as Admin
140-
* **WinRM errors in remote mode** → Enable remoting with:
182+
- **sqlcmd not found**
183+
→ Install SQL Server Command Line Utilities
184+
185+
- **Get-WsusServer fails**
186+
→ Ensure WSUS Admin Console is installed
141187

142-
```powershell
143-
Enable-PSRemoting -Force
144-
```
188+
- **Timeouts**
189+
→ Run heavy DB tasks outside business hours
190+
191+
- **WinRM Issues**
192+
```powershell
193+
Enable-PSRemoting -Force
194+
```
145195

146196
---
147197

148-
## 🔒 Scheduling & Security
198+
## 🔒 Security & Scheduling
199+
200+
- Compatible with **Task Scheduler**
201+
- Compatible with **Computer GPO Startup Scripts**
202+
- Supports **headless execution**
203+
- Safe logging and rollback‑aware workflows
204+
205+
---
149206

150-
* Use **Task Scheduler** or **GPO** for recurring maintenance (overnight)
151-
* Centralize logs by redirecting `$LogDir` to a UNC path
152-
* Always run as a **WSUS Administrator** account (least privilege recommended)
207+
© 2026 Luiz Hamilton. All rights reserved.

0 commit comments

Comments
 (0)