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


Copy-SqlSharedSchedule

This command copies SQL Agent shared schedules from one SQL Server to another. By default, all schedules are copied.

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

If the schedule already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the object. Dependencies are not currently copied over.

Examples

To copy all schedules from sqlserver2014a to sqlcluster, using integrated (Windows) authentication. If schedules with the same name exist on sqlcluster, they will be skipped.

To copy only two schedules, weekly and daily, from sqlserver2014a to sqlcluster, using SQL authentication for sqlserver2014a and integrated (Windows) authentication for sqlcluster. If a schedule with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

To see what would happen if the command were executed. No actions are actually performed.

Get-Help

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

Source Code

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

Related commands