转载请注明出自天外归云的博客园: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的更多相关文章

  1. SharePoint自动化系列——Add/Remove "Record" from items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 目的:批量的将SharePoint items变成records或者将records变成普通的it ...

  2. SharePoint自动化系列——Add content type to list.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...

  3. SharePoint自动化系列——Site/Web/List级别的导航菜单

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...

  4. SharePoint自动化系列——通过PowerShell创建SharePoint List Items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  5. SharePoint自动化系列——Create a local user and add to SharePoint

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...

  6. SharePoint自动化系列——Solution auto-redeploy using Selenium(C#)

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 本来的想法是做一个可以自动卸载并且部署新solution到SharePoint farm的tool ...

  7. SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...

  8. SharePoint自动化系列——通过PowerShell在SharePoint中批量做数据

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...

  9. SharePoint自动化系列——创建MMS terms

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...

随机推荐

  1. java系统时间的调用和格式转换

    java在java.text   java.util   java.lang包中查找 import java.util.*; import java.text.*; public class Text ...

  2. [转]史上最全的MSSQL复习笔记

    阅读目录 1.什么是SQL语句 2.使用sql语句创建数据库和表 3.创建数据表 4.数据完整性约束 5.四中基本字符类型说明 6.SQL基本语句 7.类型转换函数 8.日期函数 9.数学函数 10. ...

  3. DataBase: LeetCode

    Combine Two Tables # Write your MySQL query statement below Select p.FirstName, p.LastName, a.City, ...

  4. 活动组件(三):Intent

    大多数的安卓应用都不止一个Activity,而是有多个Activity.但是点击应用图标的时候,只会进入应用的主活动. 因此,前面我已经建立了一个主活动了,名字是myActivity,现在我再建立一个 ...

  5. ligerui+json_001_实现表格(grid)的后台数据显示、分页

    代码下载地址: http://download.csdn.net/detail/poiuy1991719/8556841 效果: 需要导入的包: 01:编写界面:index.jsp <%@ pa ...

  6. java 枚举类小结 Enum

    好久没有接触枚举类了,差不多都忘了,今天抽出个时间总结一下吧.说实话,枚举类确实能够给我们带来很大的方便. 说明:枚举类它约定了一个范围,可以理解成只可以生成固定的几个对象让外界去调用,故枚举类中的构 ...

  7. oracle中的常用语句

    1:查看当前用户的缺省表空间 SELECT USERNAME, DEFAULT_TABLESPACE FROM USER_USERS; 2:查看当前用户的角色 SELECT * FROM USER_R ...

  8. 夺命雷公狗—angularjs—8—ng-class的简单用法

    我们在正常的业务处理中往往会遇到一些逻辑类的问题,比如各行换色,现在angularjs里面也给我们提供了一个小小的的class处理的方式,废话不多说,如下所示: <!doctype html&g ...

  9. AMBA interconnector PL301(一)

    HPM(High-Performance Matrix)是一个自生成的AMBA3 bus subsystem. 由一个AXI bus matrix,Frequency Conversion Compo ...

  10. 为什么在我眼里你是一只傻逼——傻逼“常所用”句型之(2)——“当当网的就有XXX人评论,YYY%的推荐”

    A:这东西里面尽是大粪. B:这东西当当网的就有325人评论,98.8%的推荐.京东的整体评论是五星,37人评价,31人给好评,1人差评,5人中评:亚马逊有6条好评,1条中评. http://news ...