|
4 | 4 |
|
5 | 5 | ## 📝 Overview |
6 | 6 |
|
7 | | -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)**. |
| 7 | +The **WSUS Management Tools** suite provides an enterprise-grade, **auditable PowerShell maintenance tool** for **Windows Server Update Services (WSUS)**, including end-to-end care of **SUSDB** on **Windows Internal Database (WID)** or full SQL Server. |
8 | 8 |
|
9 | | -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**. |
| 9 | +This repository is aligned with the same **GUI, logging, safety, and execution standards** used across **Windows‑SysAdmin‑ProSuite** and is designed for **corporate WSUS operations** (repeatable runs, strong guardrails, predictable outputs, and safe defaults). |
10 | 10 |
|
11 | | -They are built to reduce operational risk, improve database performance, and provide **auditable, repeatable WSUS maintenance workflows**. |
| 11 | +✅ **Current flagship (all-in-one):** `Maintenance-WSUS-Admin-Tool.ps1` |
| 12 | +This single script consolidates the legacy helper scripts into one hardened GUI tool. |
12 | 13 |
|
13 | 14 | --- |
14 | 15 |
|
15 | 16 | ## ✅ Key Features |
16 | 17 |
|
17 | | -- 🖥️ **GUI‑Driven Maintenance** |
18 | | - Perform complex WSUS tasks without command-line interaction |
19 | | - |
20 | | -- 🗄️ **SUSDB Health & Performance** |
21 | | - - Fragmentation analysis |
22 | | - - Smart index reorganization vs rebuild |
23 | | - - Statistics update and integrity checks |
24 | | - |
25 | | -- 🧩 **WSUS Assembly Validation** |
26 | | - - Automatic detection and loading of `Microsoft.UpdateServices.Administration.dll` |
27 | | - - Clear guidance when WSUS Admin components are missing |
28 | | - |
29 | | -- 📊 **Structured Logging & Reporting** |
30 | | - - `.log` (execution trace) |
31 | | - - `.csv` (decline counts, cleanup metrics) |
32 | | - - Timestamped, session‑scoped outputs |
33 | | - |
34 | | -- 📈 **Weighted Progress Tracking** |
35 | | - - Real progress bar capped at 100% |
36 | | - - Phased execution (decline → cleanup → database) |
37 | | - |
38 | | -- 🧱 **Enterprise‑Ready Design** |
39 | | - - Modular scripts |
40 | | - - GUI + non‑interactive execution |
41 | | - - Safe for Task Scheduler and GPO execution |
| 18 | +### 🧰 All‑in‑One WSUS Maintenance GUI |
| 19 | +- One tool for **preflight**, **inventory**, **decline**, **cleanup**, and **database maintenance** |
| 20 | +- Corporate-friendly behavior (safe-by-default execution + clear logs) |
| 21 | + |
| 22 | +### 🔎 Preflight & WSUS API Validation (Hardened) |
| 23 | +- Automatic discovery and loading of: |
| 24 | + - `Microsoft.UpdateServices.Administration.dll` |
| 25 | + - `UpdateServices` PowerShell module (when available) |
| 26 | +- WSUS Admin API connectivity test (target server/port/SSL) |
| 27 | +- Service validation and recovery helpers: |
| 28 | + - `W3SVC`, `WSUSService` |
| 29 | + - IIS AppPool: `WsusPool` recycle/start |
| 30 | + |
| 31 | +### 🧾 Environment Inventory (Exportable) |
| 32 | +- Exports **JSON + CSV summary** for auditability |
| 33 | +- Captures key WSUS/WID signals: |
| 34 | + - WSUS endpoint (server/port/SSL) |
| 35 | + - WSUS Admin API readiness |
| 36 | + - `wsusutil.exe` and `sqlcmd.exe` detection |
| 37 | + - WID / SQL connectivity validation |
| 38 | + - IIS/Services status |
| 39 | + |
| 40 | +### 🧹 Decline & Cleanup Workflow |
| 41 | +- Decline routines (policy-driven): |
| 42 | + - Unapproved (older-than threshold) |
| 43 | + - Expired |
| 44 | + - Superseded |
| 45 | + - Legacy (optional policy set) |
| 46 | +- WSUS cleanup operations: |
| 47 | + - Obsolete updates |
| 48 | + - Unneeded content files |
| 49 | + - Obsolete computers |
| 50 | + - Optional update compression (user-controlled) |
| 51 | + |
| 52 | +> Note: `CleanupObsoleteUpdates` can legitimately hit timeouts on large environments. The tool logs the timeout and continues where safe. |
| 53 | +
|
| 54 | +### 🗄️ SUSDB Health & Performance (WID / SQL) |
| 55 | +- Generates SQL scripts for repeatable database maintenance: |
| 56 | + - fragmentation verification |
| 57 | + - “smart” reindex strategy (reorganize vs rebuild) |
| 58 | + - classic maintenance script (optional) |
| 59 | +- DB integrity check: |
| 60 | + - `DBCC CHECKDB (SUSDB) WITH NO_INFOMSGS` |
| 61 | +- Uses `sqlcmd.exe` with robust argument quoting to avoid command parsing failures. |
| 62 | + |
| 63 | +### 📊 Logging, Reports, and Predictable Outputs |
| 64 | +- Single-session log file (default): |
| 65 | + - `C:\Logs-TEMP\WSUS-GUI\Logs\NEW-WSUS-TOOL.log` |
| 66 | +- Timestamped inventory and reports for audit trails |
| 67 | +- Clear step boundaries and failure visibility (INFO/WARN/ERROR) |
42 | 68 |
|
43 | 69 | --- |
44 | 70 |
|
45 | 71 | ## 🛠️ Prerequisites |
46 | 72 |
|
47 | | -### 1. ⚙️ PowerShell |
48 | | -- Windows PowerShell **5.1 or later** |
| 73 | +### 1) ⚙️ PowerShell |
| 74 | +- Windows PowerShell **5.1+** (recommended on WSUS host) |
| 75 | + |
49 | 76 | ```powershell |
50 | 77 | $PSVersionTable.PSVersion |
51 | 78 | ``` |
52 | 79 |
|
53 | | -### 2. 🔑 Administrator Privileges |
54 | | -- Must be executed **elevated** |
55 | | -- Required for WSUS API access and SUSDB maintenance |
56 | | - |
57 | | -### 3. 📦 Required Components |
58 | | - |
59 | | -- **WSUS Administration Console** |
60 | | - - Provides `UpdateServices` module |
61 | | - - Installs WSUS Admin assemblies |
| 80 | +### 2) 🔑 Administrator Privileges |
| 81 | +- Run **elevated** (required for WSUS Admin API operations, IIS actions, and DB tasks). |
62 | 82 |
|
63 | | -- **PowerShell Modules** |
64 | | - - `UpdateServices` |
65 | | - - `ActiveDirectory` *(optional, for WSUS discovery)* |
| 83 | +### 3) 📦 WSUS Administration Components |
| 84 | +- WSUS must be installed and the WSUS Admin API available: |
| 85 | + - `Microsoft.UpdateServices.Administration.dll` |
| 86 | +- Usually present on the WSUS server at: |
| 87 | + - `C:\Program Files\Update Services\Api\Microsoft.UpdateServices.Administration.dll` |
66 | 88 |
|
67 | | -### 4. 🗄️ SQLCMD Utilities |
68 | | -- Required to execute maintenance queries on WID / SUSDB |
69 | | -- Named pipe: |
| 89 | +### 4) 🗄️ SQLCMD Utilities (Required for SUSDB Maintenance) |
| 90 | +- Required to run queries against WID/SUSDB (or SQL Server). |
| 91 | +- WID named pipe (typical WSUS/WID): |
70 | 92 | ``` |
71 | 93 | np:\\.\pipe\MICROSOFT##WID\tsql\query |
72 | 94 | ``` |
73 | | -- Ensure `sqlcmd.exe` is installed and available in `PATH` |
74 | 95 |
|
75 | | -### 5. 🔧 Execution Policy |
| 96 | +**sqlcmd.exe** |
| 97 | +- The tool detects common locations (e.g. ODBC 17/18 Client SDK). |
| 98 | +- Best practice: ensure `sqlcmd.exe` is available in `PATH`. |
| 99 | + |
| 100 | +### 5) 🔧 Execution Policy (Session Only) |
76 | 101 | ```powershell |
77 | 102 | Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process |
78 | 103 | ``` |
79 | 104 |
|
80 | | -### 6. 📄 Required SQL Scripts |
81 | | -Location: |
82 | | -``` |
83 | | -C:\Logs-TEMP\WSUS-GUI\Scripts\ |
84 | | -``` |
85 | | - |
86 | | -- `wsus-verify-fragmentation.sql` |
87 | | -- `wsus-reindex-smart.sql` |
88 | | - |
89 | | -### 7. 📦 WSUS Admin Assembly |
90 | | -- `Microsoft.UpdateServices.Administration.dll` |
91 | | -- Automatically validated by: |
92 | | - - `Check-WSUS-AdminAssembly.ps1` |
93 | | - |
94 | 105 | --- |
95 | 106 |
|
96 | | -## 📜 Script Descriptions |
| 107 | +## 📜 Script Inventory |
97 | 108 |
|
98 | 109 | | Script | Purpose | |
99 | 110 | |------|--------| |
100 | | -| **Check-WSUS-AdminAssembly.ps1** | Detects and loads WSUS Admin assemblies, validates WSUS tooling | |
101 | | -| **Generate-WSUSReindexScript.ps1** | Generates adaptive reindex T‑SQL based on fragmentation thresholds | |
102 | | -| **Maintenance-WSUS-Admin-Tool.ps1** | Full GUI‑based WSUS maintenance: decline, cleanup, SUSDB optimization | |
103 | | - |
104 | | ---- |
| 111 | +| **Maintenance-WSUS-Admin-Tool.ps1** | **All-in-one** WSUS GUI: preflight, inventory export, decline & cleanup operations, SQL script generation, SUSDB maintenance (WID/SQL) | |
105 | 112 |
|
106 | | -## 🚀 Usage |
107 | | - |
108 | | -### 🖥️ WSUS Maintenance GUI |
109 | | - |
110 | | -1. Right‑click **Maintenance-WSUS-Admin-Tool.ps1** |
111 | | -2. Select **Run with PowerShell (Administrator)** |
112 | | -3. Confirm WSUS server and port (default: local FQDN / `8530`) |
113 | | -4. Select maintenance tasks |
114 | | -5. Monitor execution via GUI and logs |
| 113 | +> Legacy helper scripts (`Check-WSUS-AdminAssembly.ps1`, `Inventory-WSUSEnvironment.ps1`, `Generate-WSUSReindexScript.ps1`) were **integrated** into the main tool for a single corporate-grade workflow. They may remain in the repository for reference/testing, but the recommended operational path is the unified tool. |
115 | 114 |
|
116 | 115 | --- |
117 | 116 |
|
118 | | -### 🗄️ Generate Smart Reindex Script |
| 117 | +## 🚀 Usage |
119 | 118 |
|
120 | | -```powershell |
121 | | -.\Generate-WSUSReindexScript.ps1 |
122 | | -``` |
| 119 | +### 🖥️ Run the WSUS Maintenance GUI (Recommended) |
| 120 | + |
| 121 | +1. Copy `Maintenance-WSUS-Admin-Tool.ps1` to the WSUS host (or run from a secured share) |
| 122 | +2. Right‑click → **Run with PowerShell (Administrator)** |
| 123 | +3. Confirm: |
| 124 | + - WSUS Server (default: local FQDN) |
| 125 | + - Port (default: `8530`) |
| 126 | + - SSL (default: `False`, unless your environment uses 8531/SSL) |
| 127 | +4. Use **Preflight** first: |
| 128 | + - Admin API load |
| 129 | + - Connection test |
| 130 | + - Export inventory |
| 131 | + - Generate SQL scripts |
| 132 | +5. Execute maintenance steps and review logs/reports |
123 | 133 |
|
124 | 134 | --- |
125 | 135 |
|
126 | | -### 🧩 Validate WSUS Assemblies |
127 | | - |
128 | | -```powershell |
129 | | -.\Check-WSUS-AdminAssembly.ps1 |
130 | | -``` |
131 | | - |
132 | | ---- |
| 136 | +## 📁 Output Paths & Structure |
133 | 137 |
|
134 | | -## 📁 Supporting Files & Structure |
| 138 | +Default working directory: |
135 | 139 |
|
136 | 140 | ``` |
137 | 141 | C:\Logs-TEMP\WSUS-GUI\ |
138 | | -├── Scripts\ |
139 | 142 | ├── Logs\ |
| 143 | +│ ├── NEW-WSUS-TOOL.log |
| 144 | +│ └── Inventory\ |
| 145 | +│ ├── wsus-inventory-YYYYMMDD-HHMMSS.json |
| 146 | +│ └── wsus-inventory-summary-YYYYMMDD-HHMMSS.csv |
140 | 147 | ├── CSV\ |
141 | 148 | ├── Backups\ |
142 | 149 | └── settings.json |
143 | 150 | ``` |
144 | 151 |
|
| 152 | +Generated SQL scripts (default): |
| 153 | + |
| 154 | +``` |
| 155 | +C:\Scripts\SUSDB\ |
| 156 | +├── wsus-verify-fragmentation.sql |
| 157 | +├── wsus-reindex-smart.sql |
| 158 | +└── wsusdbmaintenance-classic.sql |
| 159 | +``` |
| 160 | + |
145 | 161 | --- |
146 | 162 |
|
147 | | -## 💡 Operational Best Practices |
| 163 | +## 💡 Operational Best Practices (Corporate WSUS) |
148 | 164 |
|
149 | | -- ⏰ Schedule maintenance overnight |
150 | | -- 🔐 Use least-privilege WSUS admin accounts |
151 | | -- 📁 Centralize logs to a UNC path |
152 | | -- 🧪 Always verify before rebuild |
| 165 | +- ⏰ Run maintenance in an **overnight window** |
| 166 | +- 📌 Prefer: **Reindex/DB maintenance → WSUS cleanup** for very large SUSDBs |
| 167 | +- 💾 Keep DB backups and logs on a dedicated volume or secured share |
| 168 | +- 🔐 Restrict execution to WSUS admins and audit all runs via exported inventory/logs |
| 169 | +- 🧪 After maintenance, validate: |
| 170 | + - WSUS console opens quickly |
| 171 | + - sync health (if upstream) |
| 172 | + - client scan/reporting behavior |
153 | 173 |
|
154 | 174 | --- |
155 | 175 |
|
156 | 176 | ## 🔒 Security & Scheduling |
157 | 177 |
|
158 | | -- Task Scheduler compatible |
159 | | -- GPO startup compatible |
160 | | -- Headless execution supported |
| 178 | +- ✅ Task Scheduler compatible |
| 179 | +- ✅ GPO startup compatible (machine context) |
| 180 | +- ✅ “Headless-friendly” execution model (logs + deterministic outputs) |
| 181 | +- ✅ No `Get-Credential` dependency |
161 | 182 |
|
162 | 183 | --- |
163 | 184 |
|
164 | | -© 2026 Luiz Hamilton Silva. All rights reserved. |
| 185 | +## 📄 License / Author |
| 186 | + |
| 187 | +© 2026 **Luiz Hamilton Silva** (@brazilianscriptguy). All rights reserved. |
0 commit comments