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

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Copy-DbaAgentCategory

This command migrates SQL Agent categories from one SQL Server to another. This is similar to sp_add_category.

By default, all SQL Agent categories for Jobs, Operators and Alerts are copied.

To migrate only one object type use the -CategoryType parameter and specify Alert, Job, or Operator.

The -OperatorCategories, -AgentCategories and-JobCategories parameters are autopopulated for command-line completion and can be used to copy only specific job categories.

If the object already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the object.

Examples

To copy over all agent categories from sqlserverinstance to sqlcluster using Windows authentication

 

To copy over all agent categories settings from sql2014 to sql2016 using SQL authentication.

 

To copy over all Job categories from sql2014 to sql2016.

 

To copy over just the ‘Migration Operator’ operator category

 

Get-Help

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

Source Code

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

Related commands