Skip to content

Commit 1b3ec7c

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

1 file changed

Lines changed: 74 additions & 48 deletions

File tree

  • SysAdmin-Tools/WSUS-Management-Tools

SysAdmin-Tools/WSUS-Management-Tools/README.md

Lines changed: 74 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ These tools are designed for **Active Directory** and **standalone** environment
88

99
## ✅ Key Features
1010
- **Graphical Interface**: Run maintenance tasks via GUI (no command line required)
11-
- **Index Optimization**: Reports fragmentation and generates **smart reindex scripts** for SUSDB
11+
- **Index Optimization**: Reports fragmentation and executes **smart reindex logic** for SUSDB
1212
- **Assembly Detection**: Validates and loads WSUS Admin assemblies from the GAC or known paths
1313
- **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)
1415
- **Modular Design**: Scripts can run standalone or be scheduled with Task Scheduler/GPO
1516

1617
---
@@ -21,106 +22,131 @@ These tools are designed for **Active Directory** and **standalone** environment
2122
- Requires **Windows PowerShell 5.1+**
2223
```powershell
2324
$PSVersionTable.PSVersion
24-
```
25+
````
26+
27+
2. **Administrator Privileges**
28+
29+
* Must be run **elevated** to access WSUS APIs and SUSDB
2530
26-
2. **Administrator Privileges**
27-
- Must be run **elevated** to access WSUS APIs and SUSDB
31+
3. **Required Modules**
2832
29-
3. **Required Modules**
30-
- `UpdateServices` (included with the WSUS Administration Console / Tools)
31-
- `ActiveDirectory` *(optional, for WSUS server discovery)*
33+
* `UpdateServices` (included with the WSUS Administration Console / Tools)
34+
* `ActiveDirectory` *(optional, for WSUS server discovery)*
3235
33-
4. **SQLCMD Tools**
34-
- Required to execute SQL scripts on SUSDB (via named pipe: `np:\\.\pipe\MICROSOFT##WID\tsql\query`)
35-
- Ensure **`sqlcmd.exe`** is installed and on your `PATH`
36+
4. **SQLCMD Tools**
37+
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`
40+
41+
5. **Execution Policy**
3642
37-
5. **Execution Policy**
3843
```powershell
3944
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
4045
```
4146

42-
6. **SQL Script Files** (copy into `C:\Logs-TEMP\WSUS-GUI\Scripts`)
43-
- `wsus-verify-fragmentation.sql`
44-
- `wsus-reindex-smart.sql`
47+
6. **SQL Script Files** (must exist in `C:\Logs-TEMP\WSUS-GUI\Scripts`)
48+
49+
* `wsus-verify-fragmentation.sql` → Reports index fragmentation (CHECK/VERIFY step)
50+
* `wsus-reindex-smart.sql` → Smart reindex logic (REORGANIZE vs REBUILD + UPDATE STATISTICS)
4551

46-
7. **WSUS Admin Assembly**
47-
- Ensure `Microsoft.UpdateServices.Administration.dll` is available in the **GAC**
48-
- Validate with **Check-WSUS-AdminAssembly.ps1**
52+
7. **WSUS Admin Assembly**
53+
54+
* Ensure `Microsoft.UpdateServices.Administration.dll` is available in the **GAC**
55+
* Validate with **Check-WSUS-AdminAssembly.ps1**
4956

5057
---
5158

5259
## 📜 Script Descriptions
5360

54-
| Script | Function |
55-
|--------|----------|
56-
| **Check-WSUS-AdminAssembly.ps1** | Detects/loads `Microsoft.UpdateServices.Administration.dll`; guides installation if missing |
57-
| **Generate-WSUSReindexScript.ps1** | Prompts thresholds and generates `wsus-reindex-smart.sql` for SUSDB index maintenance |
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 |
5865
| **Maintenance-WSUS-Admin-Tool.ps1** | GUI: decline updates (expired, superseded, unapproved), cleanup obsolete files/computers, SUSDB tasks (CHECKDB, shrink, reindex, backup) |
5966

6067
---
6168

6269
## 🚀 Usage
6370

6471
### GUI Tool
65-
1. Right-click **Maintenance-WSUS-Admin-Tool.ps1****Run with PowerShell (Admin)**
66-
2. Configure WSUS server (defaults to **local FQDN** and port `8530` if missing)
67-
3. Select maintenance tasks (check boxes)
68-
4. Run and monitor execution in the status window and log
72+
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
6977

7078
### Index Reindex Script
79+
7180
Generate a smart T-SQL script:
81+
7282
```powershell
7383
.\Generate-WSUSReindexScript.ps1
7484
```
85+
7586
The script creates `wsus-reindex-smart.sql` with logic to reorganize or rebuild indexes based on thresholds.
7687

7788
### Assembly Validation
89+
7890
Check if the WSUS Administration assembly is installed and loadable:
91+
7992
```powershell
8093
.\Check-WSUS-AdminAssembly.ps1
8194
```
8295

8396
---
8497

8598
## 📁 Complementary Files
86-
- `wsus-verify-fragmentation.sql` → SUSDB fragmentation sql call for defragmentation verify - you must copy this file from this repository to the your local folder `C:\Logs-TEMP\WSUS-GUI\Scripts\`
87-
- `wsus-reindex-smart.sql` → Smart reindex logic (skip low pages, reorganize vs rebuild) - you must copy this file from this repository to the your local folder `C:\Logs-TEMP\WSUS-GUI\Scripts\`
88-
- `settings.json` → GUI persistence file that will be created at the first `Maintenance-WSUS-Admin-Tool.ps1` execution
89-
- `Logs\` → Example: `Maintenance-WSUS-Admin-Tool-20250915-095431.log`
99+
100+
* `wsus-verify-fragmentation.sql`
101+
**Reports fragmentation** levels per index in SUSDB. Use this to decide whether reindexing is required.
102+
103+
* `wsus-reindex-smart.sql`
104+
**Executes smart reindexing**: skips low-page indexes, reorganizes medium fragmentation, rebuilds high fragmentation, updates statistics.
105+
106+
* `settings.json`
107+
→ GUI persistence file created at first run of `Maintenance-WSUS-Admin-Tool.ps1`
108+
109+
* `Logs\`
110+
→ Example: `Maintenance-WSUS-Admin-Tool-20250915-095431.log`
90111

91112
---
92113

93114
## 💡 Tips
94-
- **Logs & Configs**
95-
- Scripts: `C:\Logs-TEMP\WSUS-GUI\Scripts\`
96-
- Logs: `C:\Logs-TEMP\WSUS-GUI\Logs\`
97-
- CSV: `C:\Logs-TEMP\WSUS-GUI\CSV\`
98-
- Backups: `C:\Logs-TEMP\WSUS-GUI\Backups\`
99-
- Settings: `C:\Logs-TEMP\WSUS-GUI\settings.json`
100115

101-
- **Console Visibility**
102-
- GUI hides the console window by default
103-
- Comment out the *Hide Console* block in scripts while debugging
116+
* **Logs & Configs**
117+
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`
104123

105-
- **Timeout Handling**
106-
- Some WSUS builds lack `DatabaseCommandTimeout`; this is logged as `[DEBUG]`
107-
- **CompressUpdates** may time out — run standalone during off-hours if needed
124+
* **Console Visibility**
125+
126+
* GUI hides the console window by default
127+
* Comment out the *Hide Console* block in scripts while debugging
128+
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
108133

109134
---
110135

111136
## 🧰 Troubleshooting
112137

113-
- **`sqlcmd.exe` not found** → Install SQL Server Command Line Utilities and add to PATH
114-
- **`Get-WsusServer failed`** → Ensure WSUS Admin Console is installed and run PowerShell as Admin
115-
- **WinRM errors in remote mode** → Enable remoting with:
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:
141+
116142
```powershell
117143
Enable-PSRemoting -Force
118144
```
119145

120146
---
121147

122148
## 🔒 Scheduling & Security
123-
- Use **Task Scheduler** or **GPO** for recurring maintenance (overnight)
124-
- Centralize logs by redirecting `$LogDir` to a UNC path
125-
- Always run as a **WSUS Administrator** account (least privilege recommended)
126-
149+
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)

0 commit comments

Comments
 (0)