How to get all the job definitions in the SharePoint farm

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.SharePoint.Administration;

 

namespace ConsoleApplication

{

    class Program

    {

        static void Main(string[] args)

        {

            foreach (SPService service in SPFarm.Local.Services)

            {

                foreach (SPJobDefinition jobDefinition in service.JobDefinitions)

                {

                  //Display all the timer jobs

                    Console.WriteLine(jobDefinition.Name.ToString());

                    //To start the particular timer job immediately

                    if (jobDefinition.Name == "Word Automation Services")

                    {

                        jobDefinition.RunNow();

                    }                

                }

            }

            Console.ReadLine();

        }

    }

}


jobDefinitions.png

Ebook Download
View all
Learn
View all