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()
Facing issues? Have Questions? Post them here! I am happy to answer!
- error CAML Query containing special characters
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion
- Trigger Flow on selected Listitem from SharePoint view - create button with JSON column formatting
- SharePoint Excel error - The workbook cannot be opened because it contains the following features that are not supported by Excel in the browser
- Send Email with attachment using SharePoint PowerShell, SMTP server
- How to show or hide columns in SharePoint Online List Library from
- SharePoint excel error - A problem occurred while connecting to the server. If the problem continues, contact your administrator.
- How to get SharePoint Online user details from person or group column using REST API
- How to get SharePoint List Item URL using PowerShell
- How to get the SharePoint Tenant Login URL
- Special character & not working with SharePoint REST API
- How to disable SharePoint subsite creation option for owners
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- Deploy SharePoint wsp solution package using PowerShell
- How to create classic site in SharePoint Online
- See actual SharePoint error exception modify web.config
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5
- How to add animated Gif to SharePoint Online Page
- [Solved] SharePoint Search Internal server error exception
- How to create SharePoint Document Library
- SharePoint - Use Today's Date Time in list view filter and calculated column
- How to redirect SharePoint Site Collection to different URL
- SharePoint error cannot connect to the configuration database
- Run Gradle Build without test cases - Gradle
- [Fix] Microsoft 53003 Error - Microsoft
- Bash Command To Get Current Time - Bash
- [macOS] Change homepage Macbook Safari Browser - MacOS
- How to serialize-deserialize an object in java - Java
- ls command sort by file size [Linix/UNIX/macOS/bash] - Linux
- How to URLEncode a Query String in Python - Python
- Fix - sudo: systemctl: command not found - Ubuntu