dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Copy-SqlExtendedEvent

This command migrates SQL Extended Event Sessions. By default, all events are copied except the two system events, AlwaysOn_health and system_health.

The -Sessions parameter is autopopulated for command-line completion and can be used to copy only specific objects.

If the event already exists on the destination, it will be skipped unless -Force is used. If -Force is specified, the event will be dropped and recreated.

Examples

To copy all policies and conditions from sqlserver2014a to sqlcluster, using Windows credentials.

To copy all policies and conditions from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.

To copy two Extended Events, CheckQueries and MonitorUserDefinedException, from sqlserver2014a to sqlcluster.

To show what would happen if the command was executed. This does not perform any actions.

Get-Help

From PowerShell, execute Get-Help Copy-SqlExtendedEvent -Detailed for more information on this function.

Source Code

Want to see the source code? View Copy-SqlExtendedEvent.ps1 on GitHub
 

Related commands