SharePoint自动化系列——Add/Remove “Hold” from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
问题1:
1.如果SharePoint item被添加了hold,通过UI界面来对SharePoint items解锁是比较折腾的。
2.而且这其中存在一个问题,我们可以看作是已知问题——对于文件的解锁,是可以通过UI界面完成的;而对于list中的items,我们通过UI界面是无法完成解锁的,因为当你在item中上传附件并对其添加hold后,你是无法通过item的Property->Advanced再进入Compliance details中的,所以无法完成对item附件的解锁。
而对于以上的两个问题——解锁过程的繁琐和无法解锁,我们可以通过一个脚本来解决:
Add-PSSnapin Microsoft.SharePoint.PowerShell
function RemoveHolds($siteURL,$listTitle)
{
$site = Get-SPSite $siteURL
$web = $site.RootWeb
$list = $web.Lists[$listTitle]
$items = $list.Items
$holds = $web.Lists["Holds"].Items
$holdsCount = $holds.Count
Write-Host "Holds in this site:" -ForegroundColor DarkCyan
for($i=0;$i -lt $holdsCount;$i++)
{
$tip = "["+$i+"] "+$holds[$i].title
Write-Host $tip -ForegroundColor DarkYellow
}
$choose = Read-Host "Choose the hold you wanna remove from items"
$itemHold = $web.Lists["Holds"].items[[int]$choose]
[Microsoft.Office.RecordsManagement.Holds.Hold]::RemoveHold($items,$itemHold,"Hold removed from all the items")
$web.Dispose()
$site.Dispose()
}
$siteURL = "http://exhv-3073/sites/1116site1"
$listTitle = "1116docLib"
RemoveHolds $siteURL $listTitle
直接在PowerShell或者PowerShell ise中运行这段脚本:
如上所示,在输入siteURL和listTitle后运行程序,选择相应的hold,就可以对list中的items进行解锁了。解锁后的items就可以正常进行编辑或删除了。
问题2:
1.为items添加hold和remove hold from items一样麻烦;
2.无法批量地为items添加hold。
同样用一个脚本解决,只需要将上段代码中稍作修改即可:
Add-PSSnapin Microsoft.SharePoint.PowerShell
function AddHolds($siteURL,$listTitle)
{
$site = Get-SPSite $siteURL
$web = $site.RootWeb
$list = $web.Lists[$listTitle]
$items = $list.Items
$holds = $web.Lists["Holds"].Items
$holdsCount = $holds.Count
Write-Host "Holds in this site:" -ForegroundColor DarkCyan
for($i=0;$i -lt $holdsCount;$i++)
{
$tip = "["+$i+"] "+$holds[$i].title
Write-Host $tip -ForegroundColor DarkYellow
}
$choose = Read-Host "Choose the hold you wanna add to items"
$itemHold = $web.Lists["Holds"].items[[int]$choose]
[Microsoft.Office.RecordsManagement.Holds.Hold]::SetHold($items,$itemHold,"Hold added")
$web.Dispose()
$site.Dispose()
}
$siteURL = "http://exhv-3073/sites/1116site1"
$listTitle = "1118docLib"
AddHolds $siteURL $listTitle
直接在PowerShell或者PowerShell ise中运行这段脚本:
另,一键执行所有和Hold processing and reporting的jobs:
#Run the 'Hold processing and reporting'timer jobs.
$jobs = Get-SPTimerJob|where{$_.name -like '*hold*'}
foreach($job in $jobs)
{
Start-SPTimerJob $job
}
或:
Get-SPTimerJob|where{$_.name -like '*Hold*'}|Start-SPTimerJob
参考文献:
How to add to a hold using Powershell and Programmatically in SharePoint 2010
How to remove from a hold using PowerShell and programmatically in SharePoint 2010
SharePoint自动化系列——Add/Remove “Hold” from items的更多相关文章
- SharePoint自动化系列——Add/Remove "Record" from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 目的:批量的将SharePoint items变成records或者将records变成普通的it ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Site/Web/List级别的导航菜单
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...
- SharePoint自动化系列——通过PowerShell创建SharePoint List Items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——Create a local user and add to SharePoint
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...
- SharePoint自动化系列——Solution auto-redeploy using Selenium(C#)
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 本来的想法是做一个可以自动卸载并且部署新solution到SharePoint farm的tool ...
- SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...
- SharePoint自动化系列——通过PowerShell在SharePoint中批量做数据
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...
- SharePoint自动化系列——创建MMS terms
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...
随机推荐
- :“boost/serialization/string.hpp”: No such file or directory 错误
主要原因是没有安装和配置boost库. 解决:http://www.programlife.net/boost-compile-and-config.html
- JQuery下CheckBox全选全不选反选
<script src="JS/jquery-1.7.1.js"></script> <script type="text/javascri ...
- [原创]java WEB学习笔记51:国际化 概述,API 之 locale类,dataFormat类,numberFormat类, MessageFormat类,ResourceBundle 类
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- MyEclipse下如何安装svn插件
方法一:在线安装 1.打开HELP->MyEclipse Configuration 不过多数情况下再myeclipse实现不了 Center.切换到SoftWare标签页. 2.点击 ...
- C++之路进阶——优先队列优化最短路径算法(dijkstra)
一般的dijkstra算法利用贪心的思想,每次找出最短边,然后优化到其他点的的距离,我们还采用贪心思路,但在寻找最短边进行优化,之前是双重for循环,现在我们用优先队列来实现. 代码解释: //样例程 ...
- 简单常用的sql,统计语句,陆续整理添加吧
1. 分段统计分数 if object_id('[score]') is not null drop table [score] go create table [score]([学号] i ...
- spark sql cache
1.几种缓存数据的方法 例如有一张hive表叫做activity 1.CACHE TABLE //缓存全表 sqlContext.sql("CACHE TABLE activity" ...
- 必备的 Java 参考资源列表(转)
包含必备书籍.站点.博客.活动等参考资源的完整清单级别: 初级 Ted Neward, 主管,ThoughtWorks, Neward & Associates 2009 年 3 月 02 日 ...
- oracle的面试问题
1. Oracle跟SQL Server 2005的区别? 宏观上: 1). 最大的区别在于平台,oracle可以运行在不同的平台上,sql server只能运行在windows平台上,由于windo ...
- Java 的局部变量和成员变量
在Java语言中没有全局变量 分析各种变量的作用域的最简单方法是以花括号为界, 1.在类体中定义的是成员变量,成员变量会被默认初始化 2.在方法中定义的是局部变量,局部变量不会被默认初始化