< Back

Import-DbaXESessionTemplate

Mon Jan 13, 2020 12:03 pm

NAME Import-DbaXESessionTemplate



SYNOPSIS

Imports a new XESession XML Template





SYNTAX

Import-DbaXESessionTemplate [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>

[[-SqlCredential] <Pscredential>] [[-Name] <String>] [[-Path] <System.String[]>] [[-Template] <System.String[]>]

[[-TargetFilePath] <String>] [[-TargetFileMetadataPath] <String>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Imports a new XESession XML Template either from the dbatools repository or a file you specify.





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



-Name [<String>]

The Name of the session to create.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<System.String[]>]

The path to the xml file or files for the session(s).



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 [<Sqlcollaborative.Dbatools.Parameter.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



-TargetFileMetadataPath [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-TargetFilePath [<String>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Template [<System.String[]>]

Specifies the name of one of the templates from the dbatools repository. Press tab to cycle through the

provided templates.



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:\\>Import-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats



Creates a new XESession named db_query_wait_stats from the dbatools repository to the SQL Server sql2017.

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Import-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats -Name "Query Wait Stats"



Creates a new XESession named "Query Wait Stats" using the db_query_wait_stats template.

-------------------------- EXAMPLE 3 --------------------------



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.

-------------------------- EXAMPLE 4 --------------------------



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.



RELATED LINKS

https://dbatools.io/Import-DbaXESessionTemplate