转载请注明出自天外归云的博客园: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”执行:

运行结果如下:

最新文章

  1. [麦先生]Laravel框架实现发送短信验证
  2. Win64位操作系统无法运行暗黑2战网D2GS的解决办法
  3. Java网页数据采集器[下篇-数据查询]【转载】
  4. ADT(android-bundler) HTML EDIT 编辑 xml HTML
  5. phpwind9.0 顶部和底部版权信息永久性修改
  6. wampserver php 设置时间
  7. BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草( dp )
  8. Move WriteBuffer ReadBuffer String
  9. hosts文件不显示
  10. schema 对象的简单介绍
  11. Java内存原型分析
  12. spring学习笔记(一) Spring概述
  13. python实现的txt目录树
  14. MYSQL根据节点向上和向下查询所有节点
  15. js 数组随机洗牌
  16. INotifyPropertyChanged
  17. SpringBoot入坑-配置文件使用
  18. Linux时间命令
  19. 2-[Mysql]- 初识sql语句
  20. linux expect 的使用

热门文章

  1. [原创]java WEB学习笔记63:Struts2学习之路--表单标签 用户注册模块
  2. Python学习总结19:类(一)
  3. oracle 复杂语句
  4. [转]ms sql 2000 下批量 附加/分离 数据库(sql语句)
  5. logstash学习2
  6. logstash的性能测试
  7. oracle的表空间
  8. Sinatra+SQLite3+DataMapper - 十分完整的tutorial - “Superdo”
  9. dota玩家与英雄契合度的计算器,python语言scrapy爬虫的使用
  10. jquery中的each用法以及js中的each方法实现实例