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


Watch-DbaXEventSession

Watch live XEvent Data as it happens – this command runs until you kill the PowerShell session or Ctrl-C.

Thanks to Dave Mason for some straightforward code samples.

Screenshots

dbatools-Watch-DbaXEventSession

Examples

Shows events for the system_health session as it happens.

Watch-DbaXEventSession -SqlInstance ServerA\sql987 -Session system_health

Also shows events for the system_health session as it happens and expands the Fields property. Looks a bit like this.

Name Type Value
—- —- —–
id System.UInt32 0
timestamp System.UInt64 0
process_utilization System.UInt32 0
system_idle System.UInt32 99
user_mode_time System.UInt64 8906250
kernel_mode_time System.UInt64 468750
page_faults System.UInt32 60
working_set_delta System.Int64 0
memory_utilization System.UInt32 99

Get-DbaXEventSession -SqlInstance sql2016 -Session system_health | Watch-DbaXEventSession | Select -ExpandProperty Fields

Author

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

Get-Help

From PowerShell, execute Get-Help Watch-DbaXEventSession -Detailed for more information on this function.

Source Code

Want to see the source code? View Watch-DbaXEventSession.ps1 on GitHub
 

Related commands