Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Watch-DbaXESession on GitHub.
Want to see the Bill Of Health for this command? Check out Watch-DbaXESession.
Watch live XEvent Data as it happens
Watch live XEvent Data as it happens. This command runs until you stop the session, kill the PowerShell session, or Ctrl-C.
Thanks to Dave Mason (@BeginTry) for some straightforward code samples https://itsalljustelectrons.blogspot.be/2017/01/SQL-Server-Extended-Event-Handling-Via-Powershell.html
Watch-DbaXESession
[[-SqlInstance] <DbaInstanceParameter>]
[[-SqlCredential] <PSCredential>]
[[-Session] <String>]
[[-InputObject] <Session[]>]
[-Raw]
[-EnableException]
[<CommonParameters>]
PS C:\> Watch-DbaXESession -SqlInstance sql2017 -Session system_health
Shows events for the system_health session as it happens.
PS C:\> Watch-DbaXESession -SqlInstance sql2017 -Session system_health | Export-Csv -NoTypeInformation -Path C:\temp\system_health.csv
Exports live events to CSV. Ctrl-C may not not cancel out of it - fastest way is to stop the session.
PS C:\> Get-DbaXESession -SqlInstance sql2017 -Session system_health | Start-DbaXESession | Watch-DbaXESession | Export-Csv -NoTypeInformation -Path C:\temp\system_health.csv
Exports live events to CSV. Ctrl-C may not not cancel out of this. The fastest way to do so is to stop the session.
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Only return a specific session. Options for this parameter are auto-populated from the server.
Alias | Name |
Required | False |
Pipeline | false |
Default Value |
Accepts an XESession object returned by Get-DbaXESession.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
If this switch is enabled, the enumeration object is returned.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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 |