Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Import-DbaXESessionTemplate on GitHub.
Want to see the Bill Of Health for this command? Check out Import-DbaXESessionTemplate.
Imports a new XESession XML Template
Imports a new XESession XML Template either from the dbatools repository or a file you specify.
Import-DbaXESessionTemplate
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[[-Name] <String>]
[[-Path] <String[]>]
[[-Template] <String[]>]
[[-TargetFilePath] <String>]
[[-TargetFileMetadataPath] <String>]
[[-StartUpState] <String>]
[-EnableException]
[<CommonParameters>]
PS C:\> Import-DbaXESessionTemplate -SqlInstance sql2017 -Template "15 Second IO Error"
Creates a new XESession named "15 Second IO Error" from the dbatools repository to the SQL Server sql2017.
PS C:\> Import-DbaXESessionTemplate -SqlInstance sql2017 -Template "Index Page Splits" -StartUpState On
Creates a new XESession named "Index Page Splits" from the dbatools repository to the SQL Server sql2017, starts the XESession and sets the StartUpState to On so that it starts on the next server
restart.
PS C:\> Import-DbaXESessionTemplate -SqlInstance sql2017 -Template "Query Wait Statistics" -Name "Query Wait Stats" | Start-DbaXESession
Creates a new XESession named "Query Wait Stats" using the Query Wait Statistics template, then immediately starts it.
PS C:\> Get-DbaXESession -SqlInstance sql2017 -Session 'Database Health 2014' | Remove-DbaXESession
PS C:\> Import-DbaXESessionTemplate -SqlInstance sql2017 -Template 'Database Health 2014' | Start-DbaXESession
Removes a session if it exists, then recreates it using a template.
PS C:\> Get-DbaXESessionTemplate | Out-GridView -PassThru | Import-DbaXESessionTemplate -SqlInstance sql2017
Allows you to select a Session template then import to an instance named sql2017.
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 | True |
Pipeline | true (ByValue) |
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 |
The Name of the session to create.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The path to the xml file or files for the session(s).
Alias | FullName |
Required | False |
Pipeline | true (ByPropertyName) |
Default Value |
Specifies the name of one of the templates from the dbatools repository. Press tab to cycle through the provided templates.
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, files will be created in the default xel directory. Use TargetFilePath to change all instances of
filename = "file.xel" to filename = "$TargetFilePath\file.xel". Only specify the directory, not the file itself.
This path is relative to the destination directory
Alias | |
Required | False |
Pipeline | false |
Default Value |
By default, files will be created in the default xem directory. Use TargetFileMetadataPath to change all instances of
filename = "file.xem" to filename = "$TargetFilePath\file.xem". Only specify the directory, not the file itself.
This path is relative to the destination directory
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the start up state of the session. The default is Off.
Alias | |
Required | False |
Pipeline | false |
Default Value | Off |
Accepted Values | On,Off |
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 |