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


This script removes Extended Events sessions on a SQL Server instance.




Removes all Extended Event Session on the sqlserver2014 instance.

Remove-DbaXESession -SqlInstance sql2012 -AllSessions

Removes the xesession1 and xesession2 Extended Event sessions.

Remove-DbaXESession -SqlInstance sql2012 -Session xesession1,xesession2

Removes all sessions from sql2017, bypassing prompting.

Get-DbaXESession -SqlInstance sql2017 | Remove-DbaXESession -Confirm:$false

Removes the sessions returned from the Get-DbaXESession function.

Get-DbaXESession -SqlInstance sql2012 -Session xesession1 | Remove-DbaXESession


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


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

Source Code

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

Related commands