dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


New-DbaXESession

Creates a new XESession object – for the dogged (very manual, Import-DbaXESession is recommended). See the following for more info: Microsoft

Screenshots

dbatools-New-DbaXESession

Examples

Returns a new XE Session object from sql2017 then adds an event, an action then creates it.

$session = New-DbaXESession -SqlInstance sql2017 -Name XeSession_Test
$event = $session.AddEvent(“sqlserver.file_written”)
$event.AddAction(“package0.callstack”)
$session.Create()

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.

Get-Help

From PowerShell, execute Get-Help New-DbaXESession -Detailed for more information on this function.

Source Code

Want to see the source code? View New-DbaXESession.ps1 on GitHub
 

Related commands