Thor Logo dbatools

New-DbaDiagnosticAdsNotebook

View Source
Gianluca Sartori (@spaghettidba)
Windows, Linux, macOS

Synopsis

Generates a Jupyter Notebook containing Glenn Berry’s SQL Server diagnostic queries for Azure Data Studio

Description

Converts Glenn Berry’s well-known SQL Server diagnostic queries into a Jupyter Notebook (.ipynb) file that can be opened and executed in Azure Data Studio. The function automatically detects your SQL Server version or accepts a target version parameter, then creates a notebook with version-specific diagnostic queries formatted as executable cells. Each query includes descriptive markdown explaining what it measures and why it’s useful for performance troubleshooting and health monitoring.

Syntax

New-DbaDiagnosticAdsNotebook
    [[-SqlInstance] <DbaInstanceParameter>]
    [[-SqlCredential] <PSCredential>]
    [[-TargetVersion] <String>]
    [-Path] <String>
    [-IncludeDatabaseSpecific]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> New-DbaDiagnosticAdsNotebook -SqlInstance localhost -Path c:\temp\myNotebook.ipynb

Creates a new Jupyter Notebook named “myNotebook” based on the version of diagnostic queries found at localhost

Example: 2
PS C:\> New-DbaDiagnosticAdsNotebook -TargetVersion 2016SP2 -Path c:\temp\myNotebook.ipynb

Creates a new Jupyter Notebook named “myNotebook” based on the version “2016SP2” of diagnostic queries

Example: 3
PS C:\> New-DbaDiagnosticAdsNotebook -TargetVersion 2017 -Path c:\temp\myNotebook.ipynb -IncludeDatabaseSpecific

Creates a new Jupyter Notebook named “myNotebook” based on the version “2017” of diagnostic queries, including database-specific queries

Required Parameters

-Path

Specifies the full file path where the Jupyter Notebook (.ipynb file) will be created. The directory must exist and you must have write permissions to the location.
The generated notebook can be opened in Azure Data Studio or any Jupyter-compatible environment for executing Glenn Berry’s diagnostic queries.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. Defaults to the default instance on localhost.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-TargetVersion

Specifies the SQL Server version to generate diagnostic queries for when not connecting to a live instance. Use this when creating notebooks for offline analysis or different environments than your
current connection.
Must be one of “2005”, “2008”, “2008R2”, “2012”, “2014”, “2016”, “2016SP2”, “2017”, “2019”, “2022”, “AzureSQLDatabase”. Cannot be used together with SqlInstance parameter.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
Accepted Values2005,2008,2008R2,2012,2014,2016,2016SP2,2017,2019,2022,AzureSQLDatabase
-IncludeDatabaseSpecific

Includes database-level diagnostic queries in addition to the default instance-level queries. These queries examine database-specific performance metrics, index usage, and database settings.
Use this when you need detailed analysis of individual databases rather than just server-wide diagnostics. Defaults to $false.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value