Copy-DbaAgentAlert migrates alerts from one SQL Server to another.

By default, all alerts are copied. The -Alert parameter is auto-populated for command-line completion and can be used to copy only specific alerts.
If the alert already exists on the destination, it will be skipped unless -Force is used.


dbatools - Copy-DbaAgentAlert


Copies all alerts from sqlserver2014a to sqlcluster using Windows credentials. If alerts with the same name exist on sqlcluster, they will be skipped.

Copy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster

Copies a only the alert named PSAlert from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a alert with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

Copy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -Alert PSAlert -SourceSqlCredential $cred -Force

Shows what would happen if the command were executed using force.

Copy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter and his blog.