zoukankan      html  css  js  c++  java
  • SharePoint自动化系列——Content Type相关timer jobs一键执行

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/

    背景:

    在SharePoint Central Administration->Monitoring->Job Definitions中我们可以看到所有的timer jobs,其中和Content Type相关的timer jobs有:

      1.Content Type Hub

      2.Content Type Sucscriber(job definition的数量等于于web application的数量)

    原因:

    由于在web application数量较多的时候,我们在publish一个content type后要将以上所有的job都跑一遍,在UI界面上操作是非常麻烦的!而且容易重复跑或没跑到。所以需要一段脚本来自动执行所有的和content type相关的jobs,脚本内容如下:

    #Start the SharePoint content type relative jobs.
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    $ContentTypeHubJob = Get-SPTimerJob|where{$_.name -like '*MetadataHubTimerJob*'}
    $ContentTypeSubscriberJobs = Get-SPTimerJob|where{$_.name -like '*MetadataSubscriberTimerJob*'}
    Start-SPTimerJob $ContentTypeHubJob
    foreach($job in $ContentTypeSubscriberJobs)
    {
        Start-SPTimerJob $job
    }
    $tip = "'Content Type Hub' job's LastRunTime is: " + $ContentTypeHubJob.LastRunTime
    Write-Host  $tip -ForegroundColor Green 
    for($i=0;$i -lt $ContentTypeSubscriberJobs.count;$i++)
    {
        $tip = "'Content Type Subscriber' job" + ($i+1) + "'s LastRunTime is: " + $ContentTypeSubscriberJobs[$i].LastRunTime 
        Write-Host $tip -ForegroundColor Green
    }
    Read-Host

    将以上内容保存到ps1类型文件中,右键点击“Run with PowerShell”执行:

    运行结果如下:

  • 相关阅读:
    flask 安装及基础学习(url_for反转,静态文件引入)
    collections 模块之Counter
    collections 数据结构模块namedtuple
    docker 私有仓库之Harbor搭建与使用
    ansible Api 2.3-2.4
    Ansible Callback
    saltstack returners
    快速入门Http协议
    小兔JS教程(五) 简单易懂的JSON入门
    小兔JS教程(四)-- 彻底攻略JS数组
  • 原文地址:https://www.cnblogs.com/LanTianYou/p/5032769.html
Copyright © 2011-2022 走看看