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


Set-DbaAgentJob

Set-DbaAgentJob updates a job in the SQL Server Agent with parameters supplied.

Screenshots

Set-DbaAgentJob

Examples

Set-DbaAgentJob -SqlInstance sql1 -Job Job1 -Disabled

Changes the job to disabled

Set-DbaAgentJob -SqlInstance sql1 -Job Job1 -OwnerLogin user1

Changes the owner of the job

Set-DbaAgentJob -SqlInstance sql1 -Job Job1 -EventLogLevel OnSuccess

Changes the job and sets the notification to write to the Windows Application event log on success

Set-DbaAgentJob -SqlInstance sql1 -Job Job1 -EmailLevel OnFailure -EmailOperator dba

Changes the job and sets the notification to send an e-mail to the e-mail operator

Set-DbaAgentJob -SqlInstance sql1 -Job Job1, Job2, Job3 -Enabled

Changes multiple jobs to enabled

Set-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job Job1, Job2, Job3 -Enabled

Changes multiple jobs to enabled on multiple servers

Set-DbaAgentJob -SqlInstance sql1 -Job Job1 -Description ‘Just another job’ -Whatif

Doesn’t Change the job but shows what would happen.

Set-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job ‘Job One’ -Description ‘Job One’

Changes a job with the name “Job1” on multiple servers to have another description

sql1, sql2, sql3 | Set-DbaAgentJob -Job Job1 -Description ‘Job One’

Changes a job with the name “Job1” on multiple servers to have another description using pipe line

Author

This command was created by Sander Stad (@sqlstad, sqlstad.nl)

Get-Help

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

Source Code

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

Related commands