< Back

ConvertTo-DbaXESession

Mon Jan 13, 2020 9:22 am

NAME ConvertTo-DbaXESession



SYNOPSIS

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

Events.





SYNTAX

ConvertTo-DbaXESession [-InputObject] <System.Object[]> [-Name] <String> [-OutputScriptOnly <Switch>]

[-EnableException <Switch>] [<CommonParameters>]





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/jonatha ... rver-2012/





PARAMETERS

-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<System.Object[]>]

Specifies a Trace object output by Get-DbaTrace.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Name [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-OutputScriptOnly [<Switch>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Trace, ExtendedEvent

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- 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.



RELATED LINKS