In this recipe, we will create the second portion of the content deployment connection, the content deployment job. We will use the content deployment path created in the Creating the content deployment path recipe.
Follow these steps to create the content deployment job:
The content deployment job defines when and how the content defined in a content deployment path should be deployed. For content deployment jobs with a repeating schedule, a SharePoint timer job will execute the job at the specific interval.
A content deployment job may also be created with PowerShell or code using the server-side object model.
Follow these steps to create the content deployment job using PowerShell:
Get-SPContentDeploymentPath
Cmdlet as follows:$path = Get-SPContentDeploymentPath "Staging Deployment Path"
SPDailySchedule
object as follows:$schedule = New-Object Microsoft.SharePoint.SPDailySchedule $schedule.BeginHour = 3
New-SPContentDeploymentJob
Cmdlet as follows:New-SPContentDeploymentJob –Name "Staging Deployment Job" –SPContentDeploymentPath $path –Schedule $schedule –ScheduleEnabled $true
Follow these steps to create the content deployment job with code using the server-side object model:
var path = Microsoft.SharePoint.Publishing.Administration.ContentDeploymentPath.GetInstance("Staging Deployment Path");
var job = Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.GetAllJobs().Add();
job.Name = "Staging Deployment Job"; job.IsEnabled = true; job.Path = path;
job.Update();
SPDailySchedule
object as follows:var schedule = new SPDailySchedule(); schedule.BeginHour = 3;
TimerJobDefintion
object of the content deployment job as follows:job.TimerJobDefinition.Schedule = schedule;
job.Update();
18.119.163.238