As a SharePoint Admin, there are a lot of cleaning, indexing, trigger workflow, and maintenance tasks that have to be performed periodically, in such a case you can make use of a timer job that can help run background processes on one or more SharePoint servers farms at a scheduled task periodically.
You can setup a timer job in SharePoint using PowerShell, by following the below steps:
Step 1:
Develop a custom timer job assembly and package it as a DLL file. The code within the assembly defines the behavior and tasks of your timer job.
Step 2:
Next, open the SharePoint Management Shell with administrative privileges.
Step 3:
Execute the following command to add the SharePoint snap-in, which provides the necessary cmdlets for managing SharePoint objects through PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell
Step 4:
Create your timer job using the below code.
$jobName = "CustomTimerJob"
$timerJob = New-Object Microsoft.SharePoint.Administration.SPJobDefinition($jobName, (Get-SPServiceApplication | where {$_.TypeName -eq "Your_Service_Application_Type"}))
Step 5:
Set the scheduler
$timerJob.Schedule = New-Object Microsoft.SharePoint.SPSchedule.Hourly
Step 6:
Now execute the below command to add the timer job to the SharePoint farm:
$timerJob.Update()
Step 7:
Finally run the scheduler,
$timerJob.RunNow()
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!