dbatools is a free PowerShell module with over 200 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


Set-DbaAgentSchedule

Set-DbaAgentSchedule updates a schedule in the msdb database.
Set-DbaAgentSchedule will help update a schedule for a job. It does not attach the schedule to a job.

Screenshots

dbatools - Set-DbaAgentSchedule

Examples

Changes the schedule for Job1 with the name ‘daily’ to enabled

Set-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -Enabled

Changes the schedule for Job1 with the name daily to have a new name weekly

Set-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -NewName weekly -FrequencyType Weekly -FrequencyInterval Monday, Wednesday, Friday

Changes the start time of the schedule for Job1 to 11 PM for multiple jobs

Set-DbaAgentSchedule -SqlInstance sql1 -Job Job1, Job2, Job3 -ScheduleName daily -StartTime ‘230000’

Changes the schedule for Job1 with the name daily to enabled on multiple servers

Set-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Job Job1 -ScheduleName daily -Enabled

Changes the schedule for Job1 with the name ‘daily’ to enabled on multiple servers using pipe line

sql1, sql2, sql3 | Set-DbaAgentSchedule -Job Job1 -ScheduleName ‘daily’ -Enabled

Author

This command was created by Sander Stad. You can find Sander on Twitter and his blog.

Get-Help

From PowerShell, execute Get-Help Set-DbaAgentSchedule -Detailed for more information on this function.

Source Code

Want to see the source code? View Set-DbaAgentSchedule.ps1 on GitHub
 

Related commands