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


Find-DbaAgentJob

Find-DbaAgentJob finds agent job(s) that fit certain search criteria. Need to find which one of your servers runs that CDC_capture or Annual_Rollup_for_Gerry job? This command helps you do just that.

Screenshots

Examples

To return all agent job(s) that have not run in 10 days.

Find-DbaAgentJob -SQLServer Dev01 -LastUsed 10

To return all agent job(s) that are either disabled, have no email notification or don’t have a schedule with detailed output.

Find-DbaAgentJob -SQLServer Dev01 -Disabled -NoEmailNotification -NoSchedule -Detailed

To return all agent job(s) that haven’t run in the last 10 days ignoring jobs “Yearly – RollUp Workload” and “SMS – Notification”.

Find-DbaAgentJob -SQLServer Dev01 -LastUsed 10 -Exclude “Yearly – RollUp Workload”, “SMS – Notification”

To return all job(s) on Dev01 that are in either category “REPL-Distribution” or “REPL-Snapshot” with detailed output.

Find-DbaAgentJob -SqlServer Dev01 -Category “REPL-Distribution”, “REPL-Snapshot” -Detailed | ft -AutoSize -Wrap

Queries CMS server to return all SQL instances in the Production folder and then list out all agent job(s( that have either been disabled or have no schedule.

Get-SqlRegisteredServerName -SqlServer CMSServer -Group Production | Find-DbaAgentJob -Disabled -NoSchedule -Detailed | ft -AutoSize -Wrap

Author

This command was created by Stephen Bennett. You can find Stephen blogging at sqlnotesfromtheunderground.wordpress.com.

Get-Help

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

Source Code

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

Related commands