1- <#
1+ <#
22. SYNOPSIS
33 Build a smart WSUS index maintenance script (wsus-reindex-smart.sql) for SUSDB (WID).
44
@@ -51,7 +51,7 @@ function Show-InputForm {
5151 $form.FormBorderStyle = ' FixedDialog'
5252 $form.MaximizeBox = $false
5353 $form.MinimizeBox = $false
54- $form.Width = 520
54+ $form.Width = 520
5555 $form.Height = 260
5656
5757 $font = New-Object System.Drawing.Font(" Segoe UI" , 9 )
@@ -99,16 +99,16 @@ function Show-InputForm {
9999 $form.AcceptButton = $btnOk
100100
101101 $form.Controls.AddRange (@ (
102- $lblMinPages , $txtMinPages ,
103- $lblReorg , $txtReorg ,
104- $lblRebuild , $txtRebuild ,
105- $hint , $btnOk
106- ))
102+ $lblMinPages , $txtMinPages ,
103+ $lblReorg , $txtReorg ,
104+ $lblRebuild , $txtRebuild ,
105+ $hint , $btnOk
106+ ))
107107
108108 if ($form.ShowDialog () -eq ' OK' ) {
109109 return @ {
110- MinPages = [int ]$txtMinPages.Text
111- ReorgPct = [double ]$txtReorg.Text
110+ MinPages = [int ]$txtMinPages.Text
111+ ReorgPct = [double ]$txtReorg.Text
112112 RebuildPct = [double ]$txtRebuild.Text
113113 }
114114 }
@@ -140,7 +140,7 @@ function Build-ReindexSqlText {
140140 [Parameter (Mandatory )] [double ] $ReorgPct ,
141141 [Parameter (Mandatory )] [double ] $RebuildPct
142142 )
143- @"
143+ @"
144144-- wsus-reindex-smart.sql
145145-- Purpose: Rebuild or reorganize fragmented indexes in SUSDB (WID-safe).
146146-- Notes:
@@ -254,21 +254,21 @@ PRINT 'Timestamp (UTC): ' + CONVERT(varchar(19), @t1, 120);
254254# -------- Main flow --------
255255try {
256256 $input = Show-InputForm
257- if (-not $input ) { [System.Windows.Forms.MessageBox ]::Show(" Operation canceled." , " WSUS Reindex (Smart)" , ' OK' , ' Information' ) | Out-Null ; exit }
257+ if (-not $input ) { [System.Windows.Forms.MessageBox ]::Show(" Operation canceled." , " WSUS Reindex (Smart)" , ' OK' , ' Information' ) | Out-Null ; exit }
258258
259259 # Validate thresholds
260260 if ($input.ReorgPct -lt 0 -or $input.RebuildPct -lt 0 -or $input.RebuildPct -le $input.ReorgPct ) {
261- [System.Windows.Forms.MessageBox ]::Show(" Invalid thresholds. Ensure: 0 <= Reorganize% < Rebuild%." , " Validation" , ' OK' , ' Error' ) | Out-Null
261+ [System.Windows.Forms.MessageBox ]::Show(" Invalid thresholds. Ensure: 0 <= Reorganize% < Rebuild%." , " Validation" , ' OK' , ' Error' ) | Out-Null
262262 exit 1
263263 }
264264 if ($input.MinPages -lt 1 ) {
265- [System.Windows.Forms.MessageBox ]::Show(" Minimum page count must be at least 1." , " Validation" , ' OK' , ' Error' ) | Out-Null
265+ [System.Windows.Forms.MessageBox ]::Show(" Minimum page count must be at least 1." , " Validation" , ' OK' , ' Error' ) | Out-Null
266266 exit 1
267267 }
268268
269269 $defaultOut = " C:\Logs-TEMP\WSUS-GUI\Scripts\wsus-reindex-smart.sql"
270270 $outFile = Get-OutputPath - DefaultPath $defaultOut
271- if (-not $outFile ) { [System.Windows.Forms.MessageBox ]::Show(" No file selected. Nothing was written." , " WSUS Reindex (Smart)" , ' OK' , ' Information' ) | Out-Null ; exit }
271+ if (-not $outFile ) { [System.Windows.Forms.MessageBox ]::Show(" No file selected. Nothing was written." , " WSUS Reindex (Smart)" , ' OK' , ' Information' ) | Out-Null ; exit }
272272
273273 $sqlText = Build-ReindexSqlText - MinPages $input.MinPages - ReorgPct $input.ReorgPct - RebuildPct $input.RebuildPct
274274
@@ -278,10 +278,10 @@ try {
278278 # UTF8 without BOM is fine; BOM also fine for sqlcmd — choose plain UTF8
279279 Set-Content - Path $outFile - Value $sqlText - Encoding UTF8
280280
281- [System.Windows.Forms.MessageBox ]::Show(" Script generated:`r`n $outFile " , " Success" , ' OK' , ' Information' ) | Out-Null
281+ [System.Windows.Forms.MessageBox ]::Show(" Script generated:`r`n $outFile " , " Success" , ' OK' , ' Information' ) | Out-Null
282282}
283283catch {
284- [System.Windows.Forms.MessageBox ]::Show(" Failed: $ ( $_.Exception.Message ) " , " Error" , ' OK' , ' Error' ) | Out-Null
284+ [System.Windows.Forms.MessageBox ]::Show(" Failed: $ ( $_.Exception.Message ) " , " Error" , ' OK' , ' Error' ) | Out-Null
285285 exit 1
286286}
287287
0 commit comments