Get-sqmBlockingHistory
PerformancesqmSQLTool v1.9.101+ · Get🔓 VIEW SERVER STATE + ALTER ANY EVENT SESSION
blocked_process_report events already captured in Extended Events ring buffers - unlike Get-sqmBlockingReport, which only shows blocking happening at the exact moment it is called. The built-in system_health session does not reliably include this event on a default installation, so this function first ensures a dedicated sqm_BlockedProcessMonitor session exists (via Register-sqmBlockedProcessMonitor, skip with -SkipMonitorSetup), then reads and de-duplicates events from both sessions. Two hard limits are surfaced in the result rather than hidden: blocked process threshold (s) is 0 (disabled) by default, so no incidents can exist until it is raised; and the ring buffer target is memory-limited and wraps around, typically covering only the last few hours on a busy instance.Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Optional | $env:COMPUTERNAME | Target SQL Server instance. |
| -SqlCredential | PSCredential | Optional | , | SQL or Windows credential. |
| -Since | datetime | Optional | , | Only return incidents at or after this timestamp. Default: no lower bound (everything still in the ring buffer). |
| -MinWaitSeconds | int | Optional | 0 | Only report incidents whose blocked-process wait time was at least this many seconds. |
| -SkipMonitorSetup | switch | Switch | $false | Skip ensuring sqm_BlockedProcessMonitor exists/is running - read only what is already there. Use with a read-only account lacking ALTER ANY EVENT SESSION. |
| -OutputPath | string | Optional | Get-sqmDefaultOutputPath\BlockingHistory | Directory for the CSV/HTML report. Only written when at least one incident is found. |
| -EnableException | switch | Switch | $false | Throw exceptions immediately instead of returning as errors. |
| -NoOpen | switch | Switch | $false | Do not automatically open the generated report. |
Execution Flow
Examples
Read past blocking incidents on the local instance
Get-sqmBlockingHistory -SqlInstance "SQL01"
Only incidents from the last 2 hours, at least 10 seconds blocked
Get-sqmBlockingHistory -SqlInstance "SQL01" -Since (Get-Date).AddHours(-2) -MinWaitSeconds 10
Check whether the threshold even allows incidents to be captured
$h = Get-sqmBlockingHistory -SqlInstance "SQL01"
if (-not $h.ThresholdConfigured) { Write-Warning "blocked process threshold is 0 - no history possible." }