From 50909783f48c90f0565d346eebd9fb7f32d47263 Mon Sep 17 00:00:00 2001
From: Vlad Drumea <48413726+VladDBA@users.noreply.github.com>
Date: Tue, 11 Jun 2024 23:49:26 +0300
Subject: [PATCH] changes for #234
---
PSBlitz.ps1 | 402 ++++++++++++++-----------------------------
Resources/styles.css | 221 ++++++++++++++++++++++++
2 files changed, 350 insertions(+), 273 deletions(-)
create mode 100644 Resources/styles.css
diff --git a/PSBlitz.ps1 b/PSBlitz.ps1
index ec9213d..25c7dff 100644
--- a/PSBlitz.ps1
+++ b/PSBlitz.ps1
@@ -256,8 +256,8 @@ param(
###Internal params
#Version
-$Vers = "4.2.0"
-$VersDate = "2024-06-10"
+$Vers = "4.2.1"
+$VersDate = "2024-06-11"
$TwoMonthsFromRelease = [datetime]::ParseExact("$VersDate", 'yyyy-MM-dd', $null).AddMonths(2)
$NowDate = Get-Date
#Get script path
@@ -276,7 +276,8 @@ $ResourceList = @("PSBlitzOutput.xlsx", "spBlitz_NonSPLatest.sql",
"GetTempDBUsageInfo.sql", "GetOpenTransactions.sql",
"GetStatsInfoForWholeDB.sql", "GetIndexInfoForWholeDB.sql",
"GetDbInfo.sql", "GetAzureSQLDBInfo.sql",
- "spBlitzQueryStore_NonSPLatest.sql", "searchtable.js", "sorttable.js")
+ "spBlitzQueryStore_NonSPLatest.sql", "searchtable.js", "sorttable.js",
+ "styles.css")
#Set path+name of the input Excel file
$OrigExcelF = $ResourcesPath + "\" + $OrigExcelFName
#Set default start row for Excel output
@@ -1309,52 +1310,8 @@ if ($ToHTML -eq "Y") {
+
@@ -1472,6 +1344,15 @@ if ($ToHTML -eq "Y") {
+"@
+ $Footer = @"
+
+
+
+
+
"@
}
else {
@@ -1672,6 +1553,7 @@ try {
@{Name = "Client Connections"; Expression = { $_."client_connections" } },
"Estimated Response Latency (Sec)",
@{Name = "Server Time"; Expression = { ($_."server_time").ToString("yyyy-MM-dd HH:mm:ss") } } | ConvertTo-Html -As Table -Fragment
+ $htmlTable1 = $htmlTable1 -replace '', ''
if (($DebugInfo) -and ($IsAzureSQLDB -eq $false)) {
Write-Host " ->Converting resource info to HTML" -fore yellow
@@ -1680,7 +1562,7 @@ try {
Write-Host " ->Skipping resource instance resource info for Azure SQL DB" -fore yellow
}
if ($IsAzureSQLDB) {
- $htmlTable2 = 'Instance resource information is not available for Azure SQL DB.
'
+ $htmlTable2 = 'Instance resource information is not available for Azure SQL DB.
'
}
else {
$htmlTable2 = $ResourceInfoTbl | Select-Object @{Name = "Logical Cores"; Expression = { $_."logical_cpu_cores" } },
@@ -1694,6 +1576,7 @@ try {
@{Name = "Available Physical Memory GB"; Expression = { $_."available_physical_memory_GB" } },
@{Name = "OS Memory State"; Expression = { $_."os_memory_state" } },
"CTP", "MAXDOP" | ConvertTo-Html -As Table -Fragment
+ $htmlTable2 = $htmlTable2 -replace '', ''
}
if ($DebugInfo) {
@@ -1705,14 +1588,16 @@ try {
@{Name = "Client Hostname"; Expression = { $_."ClientHostName" } },
@{Name = "Client IP"; Expression = { $_."ClientIP" } },
@{Name = "Protocol"; Expression = { $_."ProtocolUsed" } },
- @{Name = "Oldest Connection Time"; Expression = { $_."OldestConnectionTime" } },
+ @{Name = "Oldest Connection Time"; Expression = { ($_."OldestConnectionTime").ToString("yyyy-MM-dd HH:mm:ss") } },
@{Name = "Program"; Expression = { $_."Program" } } | ConvertTo-Html -As Table -Fragment
+ $htmlTable3 = $htmlTable3 -replace '', ''
if ($DebugInfo) {
Write-Host " ->Converting session level options info to HTML" -fore yellow
}
$htmlTable4 = $SessOptTbl | Select-Object "Option", "SessionSetting", "InstanceSetting", "Description", "URL" | ConvertTo-Html -As Table -Fragment
+ $htmlTable4 = $htmlTable4 -replace '', ''
$htmlTable4 = $htmlTable4 -replace $URLRegex, '$&'
@@ -1722,16 +1607,16 @@ try {
$HtmlTabName
-Instance information
+Instance information
$htmlTable1
-Resource information
+Resource information
$htmlTable2
-Top 10 clients by connections
+Top 10 clients by connections
$htmlTable3
-Session level options
+Session level options
$htmlTable4
@@ -1986,6 +1871,7 @@ $htmlTable4
@{Name = "Internal Objects MB"; Expression = { $_."internal_objects_MB" } },
@{Name = "User Objects MB"; Expression = { $_."user_objects_MB" } },
@{Name = "Version Store MB"; Expression = { $_."version_store_MB" } } | ConvertTo-Html -As Table -Fragment
+ $htmlTable1 = $htmlTable1 -replace '', ''
if ($DebugInfo) {
Write-Host " ->Converting TempDB table info to HTML" -fore yellow
@@ -2035,7 +1921,7 @@ $htmlTable4
$htmlTable3 = $htmlTable3 -replace $AnchorRegex, $AnchorURL
$htmlTable4 = $TempDBSessTbl | Select-Object "Query",
- @{Name = "Query Text"; Expression = { $_."query_text" } } | Where-Object -FilterScript {$_."Query Text" -ne [System.DBNull]::Value} | ConvertTo-Html -As Table -Fragment
+ @{Name = "Query Text"; Expression = { $_."query_text" } } | Where-Object -FilterScript { $_."Query Text" -ne [System.DBNull]::Value } | ConvertTo-Html -As Table -Fragment
$AnchorRegex = "$FileSOrder(_\d+)$QExt"
$AnchorURL = ' | " + "$FileSOrder" + '$1' + "$QExt"
$htmlTable4 = $htmlTable4 -replace $AnchorRegex, $AnchorURL
@@ -2333,7 +2219,7 @@ $htmlTable2
$AnchorURL = '$&'
$htmlTable1 = $htmlTable1 -replace $AnchorRegex, $AnchorURL
$htmlTable2 = $AcTranTbl | Select-Object @{Name = "Query"; Expression = { $_."current_query" } },
- @{Name = "Query text"; Expression = { $_."current_sql" } } | Where-Object -FilterScript {$_."Query text" -ne [System.DBNull]::Value} | ConvertTo-Html -As Table -Fragment
+ @{Name = "Query text"; Expression = { $_."current_sql" } } | Where-Object -FilterScript { $_."Query text" -ne [System.DBNull]::Value } | ConvertTo-Html -As Table -Fragment
$AnchorRegex = " | $FileSOrder(_\d+)$QExt"
$AnchorURL = ' | " + "$FileSOrder" + '$1' + "$QExt"
$htmlTable2 = $htmlTable2 -replace $AnchorRegex, $AnchorURL
@@ -2345,7 +2231,7 @@ $htmlTable2
#@{Name = "Wait Category"; Expression = { $_."wait_category" } },
$htmlTable3 = $AcTranTbl | Select-Object @{Name = "Query"; Expression = { $_."most_recent_query" } },
- @{Name = "Query text"; Expression = { $_."most_recent_sql" } } | Where-Object -FilterScript {$_."Query text" -ne [System.DBNull]::Value} | ConvertTo-Html -As Table -Fragment
+ @{Name = "Query text"; Expression = { $_."most_recent_sql" } } | Where-Object -FilterScript { $_."Query text" -ne [System.DBNull]::Value } | ConvertTo-Html -As Table -Fragment
$AnchorRegex = " | $FileSOrder(_\d+)$QExt"
$AnchorURL = ' | " + "$FileSOrder" + '$1' + "$QExt"
$htmlTable3 = $htmlTable3 -replace $AnchorRegex, $AnchorURL
@@ -2578,6 +2464,8 @@ $htmlTable5
$JumpToTop
Database Scoped Configuration
+
+$SortableTable
$htmlTable6
$JumpToTop
|