< Back
Watch-DbaXESession
Post
NAME Watch-DbaXESession
SYNOPSIS
Watch live XEvent Data as it happens
SYNTAX
Watch-DbaXESession [-SqlCredential <Pscredential>] [-Session <String>] [-Raw <Switch>] [-EnableException <Switch>]
[<CommonParameters>]
Watch-DbaXESession -SqlInstance <DbaInstanceParameter> [-SqlCredential <Pscredential>] [-Session <String>] [-Raw
<Switch>] [-EnableException <Switch>] [<CommonParameters>]
Watch-DbaXESession [-SqlCredential <Pscredential>] [-Session <String>] -InputObject
<Microsoft.SqlServer.Management.XEvent.Session> [-Raw <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
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 ... shell.html
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 [<Microsoft.SqlServer.Management.XEvent.Session>]
Accepts an XESession object returned by Get-DbaXESession.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Raw [<Switch>]
If this switch is enabled, the Microsoft.SqlServer.XEvent.Linq.QueryableXEventData enumeration object is
returned.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Session [<String>]
Only return a specific session. Options for this parameter are auto-populated from the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL
Server version 2008 or higher.
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: ExtendedEvent, XE, XEvent
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:\\>Watch-DbaXESession -SqlInstance sql2017 -Session system_health
Shows events for the system_health session as it happens.
-------------------------- EXAMPLE 2 --------------------------
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.
-------------------------- EXAMPLE 3 --------------------------
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.
RELATED LINKS
https://dbatools.io/Watch-DbaXESession
SYNOPSIS
Watch live XEvent Data as it happens
SYNTAX
Watch-DbaXESession [-SqlCredential <Pscredential>] [-Session <String>] [-Raw <Switch>] [-EnableException <Switch>]
[<CommonParameters>]
Watch-DbaXESession -SqlInstance <DbaInstanceParameter> [-SqlCredential <Pscredential>] [-Session <String>] [-Raw
<Switch>] [-EnableException <Switch>] [<CommonParameters>]
Watch-DbaXESession [-SqlCredential <Pscredential>] [-Session <String>] -InputObject
<Microsoft.SqlServer.Management.XEvent.Session> [-Raw <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
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 ... shell.html
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 [<Microsoft.SqlServer.Management.XEvent.Session>]
Accepts an XESession object returned by Get-DbaXESession.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Raw [<Switch>]
If this switch is enabled, the Microsoft.SqlServer.XEvent.Linq.QueryableXEventData enumeration object is
returned.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Session [<String>]
Only return a specific session. Options for this parameter are auto-populated from the server.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL
Server version 2008 or higher.
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: ExtendedEvent, XE, XEvent
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:\\>Watch-DbaXESession -SqlInstance sql2017 -Session system_health
Shows events for the system_health session as it happens.
-------------------------- EXAMPLE 2 --------------------------
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.
-------------------------- EXAMPLE 3 --------------------------
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.
RELATED LINKS
https://dbatools.io/Watch-DbaXESession