commands

^

ConvertTo-DbaXESession

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Uses a slightly modified version of sp_SQLskills_ConvertTraceToExtendedEvents.sql to convert Traces to Extended Events.

Description

Uses a slightly modified version of sp_SQLskills_ConvertTraceToExtendedEvents.sql to convert Traces to Extended Events.

T-SQL code by: Jonathan M. Kehayias, SQLskills.com. T-SQL can be found in this module directory and at https://www.sqlskills.com/blogs/jonathan/converting-sql-trace-to-extended-events-in-sql-server-2012/

Syntax

ConvertTo-DbaXESession
    [-InputObject] <Object[]>
    [-Name] <String>
    [-OutputScriptOnly]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaTrace -SqlInstance sql2017, sql2012 | Where-Object Id -eq 2 | ConvertTo-DbaXESession -Name 'Test'

Converts Trace with ID 2 to a Session named Test on SQL Server instances named sql2017 and sql2012 and creates the Session on each respective server.

Example: 2
PS C:\> Get-DbaTrace -SqlInstance sql2014 | Out-GridView -PassThru | ConvertTo-DbaXESession -Name 'Test' | Start-DbaXESession

Converts selected traces on sql2014 to sessions, creates the session, and starts it.

Example: 3
PS C:\> Get-DbaTrace -SqlInstance sql2014 | Where-Object Id -eq 1 | ConvertTo-DbaXESession -Name 'Test' -OutputScriptOnly

Converts trace ID 1 on sql2014 to an Extended Event and outputs the resulting T-SQL.

Required Parameters

-InputObject

Specifies a Trace object output by Get-DbaTrace.

Alias
Required True
Pipeline true (ByValue)
Default Value
-Name

The name of the Trace to convert. If the name exists, characters will be appended to it.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-OutputScriptOnly

Outputs the T-SQL script to create the XE session and does not execute it.

Alias
Required False
Pipeline false
Default Value False
-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.

Alias
Required False
Pipeline false
Default Value False

 

Want to see the source code for this command? Check out ConvertTo-DbaXESession on GitHub.
Want to see the Bill Of Health for this command? Check out ConvertTo-DbaXESession.