@@ -302,8 +302,8 @@ param(
302302
303303# ##Internal params
304304# Version
305- $Vers = " 5.9.0 "
306- $VersDate = " 2025-10 -13"
305+ $Vers = " 5.9.1 "
306+ $VersDate = " 2025-11 -13"
307307$TwoMonthsFromRelease = [datetime ]::ParseExact(" $VersDate " , ' yyyy-MM-dd' , $null ).AddMonths(2 )
308308$NowDate = Get-Date
309309# Get script path
@@ -326,18 +326,18 @@ $ResourceList = @("PSBlitzOutput.xlsx", "spBlitz_NonSPLatest.sql", "spBlitzCache
326326
327327# # we use these to make sure someone didn't modify the scripts in the Resources folder
328328$storedHashes = @ {
329- " spBlitz_NonSPLatest.sql" = " 6F403D76832611A2986852CCE08DE6AC63D55AE2BB2241C2E1274CD9E2252D60 "
330- " spBlitzCache_NonSPLatest.sql" = " 823327F64BE6E67ECDA5E541DC0311D0C04E2E2D540CC76FD7306933BB7763D2 "
331- " spBlitzFirst_NonSPLatest.sql" = " 3AE1F4B5B2337E7B36B25B30999543E2C2DE1C46BDF6D647394EFF7BF2944263 "
332- " spBlitzIndex_NonSPLatest.sql" = " 88FB8C452B2E2A5F5D378F045CAAA2B2E37F6B5C7C532BEF37D110D6DE59B7AA "
329+ " spBlitz_NonSPLatest.sql" = " 1612EFEEC666112A5EFAAD147804B7AF48FC522E11B63CBBD00E9D9EF529F235 "
330+ " spBlitzCache_NonSPLatest.sql" = " 098346EB1E816C8BFA59778BCE1186031549F69C068924164717D40680B5884E "
331+ " spBlitzFirst_NonSPLatest.sql" = " 65B2BEBAB1BD3F3BB6262B6EB67D159A5B799C512A6F2A7A512672D7E0501D92 "
332+ " spBlitzIndex_NonSPLatest.sql" = " 21F326BCD6BCFB57A89BBEBD34063FFC6FEFE8376BF4836650E46715134DB41D "
333333 " spBlitzLock_NonSPLatest.sql" = " 9B999A5E28ACBA871FD0545C1305B1BD6F1532F9CFACB3C910A3830CAA5FB672"
334334 " spBlitzWho_NonSPLatest.sql" = " B83BD8CBD59295DD0DFE0D25204AC6C81DEED746659844DABBED5FB4CA8D3ABA"
335335 " GetBlitzWhoData.sql" = " 1A23F1F9C4CB51252D088919500A7E472B56B98DD5096DBA79B5D96AEEB5F6FC"
336336 " GetInstanceInfo.sql" = " 29AA65809886BB2FC870B0DF49256850C4347562ABDDAD29E5BEC6D76C86036F"
337337 " GetTempDBUsageInfo.sql" = " 20620509996A6F7BB45410397D0CB5C7C0D044FEA15944950171DF14436AE9D1"
338338 " GetOpenTransactions.sql" = " 76EBCB1758CBC86DAC4FE8E5C02E88AB4B96FEDB2E21570B8C0D410FF8A69F7D"
339- " GetStatsInfoForWholeDB.sql" = " E39F52DFD9BD070F7B233880D02401AF3B72D4111FE87AEDAF1B06C45AFB730B "
340- " GetIndexInfoForWholeDB.sql" = " 6C58B79C4EDF06ADBE4EE79373A522A7C538B331D74E9E4AF32C77C6ED951F9B "
339+ " GetStatsInfoForWholeDB.sql" = " DAA08282A7FF87FDBA7604903F948F59CD0CAE09F08664F1A3CA9177121EE17B "
340+ " GetIndexInfoForWholeDB.sql" = " B8FBF199DF4E054A1700F0E27081841257BF1BA99A09E95E83EB991B2FB52D43 "
341341 " GetDbInfo.sql" = " 103B639ED78B099A5C2D133E6555B7073CE23DF2DBE4CD7CAD24D44EDB261F7F"
342342 " GetAzureSQLDBInfo.sql" = " 8A18348F7B87C2F5DA047B103E3BF4FEBB455E7498F0C93644DC2CD7E7255506"
343343 " GetObjectsWithDangerousOptions.sql" = " AFE74F2FE6D6077AEBF169CC16DE036B08980846E6795DC342372AB8C2A132A9"
@@ -722,7 +722,7 @@ function Convert-TableToHtml {
722722
723723 if (($CSSClass ) -and ($TblID )) {
724724 $htmlTableOut = $htmlTableOut -replace " <table>" , " <table id=`" $TblID `" class=`" $CSSClass `" >"
725- if ($CSSClass -like " *sortable*" ){
725+ if ($CSSClass -like " *sortable*" ) {
726726 $htmlTableOut = $htmlTableOut -replace " <th>" , " <th class=`" sortable`" >"
727727 }
728728 if ($CSSClass -eq " InstHealthTbl" ) {
@@ -737,7 +737,7 @@ function Convert-TableToHtml {
737737 } elseif ($CSSClass ) {
738738 $htmlTableOut = $htmlTableOut -replace " <table>" , " <table class=`" $CSSClass `" >"
739739 # clean up XML noise and extra charcters in specific tables
740- if ($CSSClass -like " *sortable" ){
740+ if ($CSSClass -like " *sortable" ) {
741741 $htmlTableOut = $htmlTableOut -replace " <th>" , " <th class=`" sortable`" >"
742742 } elseif ($CSSClass -eq " CacheTabx" ) {
743743 $htmlTableOut = $htmlTableOut -replace " <td><\?ClickMe " , " <td>"
@@ -3486,55 +3486,61 @@ $SortableTable `n $htmlTable `n $JumpToTop `n $HTMLBodyEnd
34863486 Invoke-PSBlitzQuery - QueryIn $Query - StepNameIn " Index Frag Info" - ConnStringIn $ConnString - CmdTimeoutIn $MaxTimeout
34873487 if ($global :StepOutcome -eq " Success" ) {
34883488 $IndexTbl = $global :PSBlitzSet.Tables [0 ]
3489- $IndexLckTbl = $global :PSBlitzSet .Tables [ 1 ]
3490- $RecordsReturned = $IndexTbl .Rows.Count
3491- if ( $RecordsReturned -le 0 ) {
3492- Write-Host " ->No rows returned ."
3489+ $ColumnCount = $IndexTbl .Columns.Count
3490+ if ( $ColumnCount -eq 1 ) {
3491+ Write-Host " ->Skipped due to database size. "
3492+ Add-LogRow " Index Frag Info " " Skipped " " Skipped due to database size ."
34933493 } else {
3494- if ($IndexLckTbl.Rows.Count -gt 0 ) {
3495- $RowNum = 0
3496- Write-Host " ->Exclusive lock detected on table(s):"
3497- $LockedTabList = " "
3498- $LockedTabLogMsg = " Exclusive locks on table(s):"
3499- foreach ($row in $IndexLckTbl ) {
3500- $LockedTab = $IndexLckTbl.Rows [$RowNum ][" object_name" ]
3501- Write-Host " - $LockedTab "
3502- if ($RowNum -eq 0 ) {
3503- $LockedTabList += " $LockedTab "
3504- } else {
3505- $LockedTabList += " , $LockedTab "
3494+ $IndexLckTbl = $global :PSBlitzSet.Tables [1 ]
3495+ $RecordsReturned = $IndexTbl.Rows.Count
3496+ if ($RecordsReturned -le 0 ) {
3497+ Write-Host " ->No rows returned."
3498+ } else {
3499+ if ($IndexLckTbl.Rows.Count -gt 0 ) {
3500+ $RowNum = 0
3501+ Write-Host " ->Exclusive lock detected on table(s):"
3502+ $LockedTabList = " "
3503+ $LockedTabLogMsg = " Exclusive locks on table(s):"
3504+ foreach ($row in $IndexLckTbl ) {
3505+ $LockedTab = $IndexLckTbl.Rows [$RowNum ][" object_name" ]
3506+ Write-Host " - $LockedTab "
3507+ if ($RowNum -eq 0 ) {
3508+ $LockedTabList += " $LockedTab "
3509+ } else {
3510+ $LockedTabList += " , $LockedTab "
3511+ }
3512+ $RowNum += 1
35063513 }
3507- $RowNum += 1
3508- }
35093514
3510- Add-LogRow " ->Index Frag Info" " Skipped XLocked Tables" " $LockedTabLogMsg $LockedTabList "
3511- }
3512- if ($ToHTML -eq " Y" ) {
3515+ Add-LogRow " ->Index Frag Info" " Skipped XLocked Tables" " $LockedTabLogMsg $LockedTabList "
3516+ }
3517+ if ($ToHTML -eq " Y" ) {
35133518
3514- Write-PSBlitzDebug " ->Converting index info to HTML"
3519+ Write-PSBlitzDebug " ->Converting index info to HTML"
35153520
3516- $htmlTable = Convert-TableToHtml $IndexTbl - TblID " StatsOrIxFragTable" - ExclCols " database" - CSSClass " sortable" - DebugInfo:$DebugInfo
3517- $HtmlTabName = " Index fragmentation info for $databaseName "
3518- $HtmlFileName = " IndexFragInfo_$databaseName .html"
3521+ $htmlTable = Convert-TableToHtml $IndexTbl - TblID " StatsOrIxFragTable" - ExclCols " database" - CSSClass " sortable" - DebugInfo:$DebugInfo
3522+ $HtmlTabName = " Index fragmentation info for $databaseName "
3523+ $HtmlFileName = " IndexFragInfo_$databaseName .html"
35193524
3520- $html = $HTMLPre + @"
3525+ $html = $HTMLPre + @"
35213526 <title>$HtmlTabName </title>`n $HTMLBodyStart `n <h1>$HtmlTabName </h1>
35223527 $ ( $SearchTableDiv -replace $STDivReplace , " 'StatsOrIxFragTable', 0" )
35233528 $SortableTable `n $htmlTable `n $JumpToTop `n $HTMLBodyEnd
35243529"@
35253530
3526- Save-HtmlFile $html $HtmlFileName $HTMLOutDir $DebugInfo
3527- Invoke-ClearVariables html, htmlTable
3528- } else {
3529- $ExcelSheet = $ExcelFile.Worksheets.Item (" Index Fragmentation" )
3530- Convert-TableToExcel $IndexTbl $ExcelSheet - StartRow $DefaultStartRow - DebugInfo:$DebugInfo
3531- # #Saving file
3532- Save-ExcelFile $ExcelFile
3531+ Save-HtmlFile $html $HtmlFileName $HTMLOutDir $DebugInfo
3532+ Invoke-ClearVariables html, htmlTable
3533+ } else {
3534+ $ExcelSheet = $ExcelFile.Worksheets.Item (" Index Fragmentation" )
3535+ Convert-TableToExcel $IndexTbl $ExcelSheet - StartRow $DefaultStartRow - DebugInfo:$DebugInfo
3536+ # #Saving file
3537+ Save-ExcelFile $ExcelFile
3538+ }
3539+ # #Cleaning up variables
3540+ Invoke-ClearVariables IndexTbl, PSBlitzSet
35333541 }
3534- # #Cleaning up variables
3535- Invoke-ClearVariables IndexTbl, PSBlitzSet
3536- }
3537- }
3542+ }
3543+ }
35383544 } else {
35393545 Write-Host " ->Skipping index fragmentation check as requested."
35403546 Add-LogRow " Index Fragmentation" " Skipped" " Index fragmentation check skipped as requested."
0 commit comments