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

目的:批量的将SharePoint items变成records或者将records变成普通的items。

1.Add records(用处不大,SharePoint中可以批量添加records,还算方便):

  1. Add-PSSnapin Microsoft.SharePoint.PowerShell
  2. function AddRecords($webURL,$listTitle)
  3. {
  4. $web = Get-SPWeb $webURL
  5. $list = $web.Lists[$listTitle]
  6. $items = $list.Items
  7. Write-Host "Start declaring..." -ForegroundColor Cyan
  8. foreach($item in $items)
  9. {
  10. $IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
  11. if ($IsRecord -eq $false)
  12. {
  13. Write-Host "Item declared" -ForegroundColor Green
  14. [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::DeclareItemAsRecord($Item)
  15. }
  16.  
  17. }
  18. }
  19. AddRecords webUrl listTitle

2.Remove records(这个用处比较大,尤其items较多时,在SharePoint中移除records是非常麻烦的事):

  1. Add-PSSnapin Microsoft.SharePoint.PowerShell
  2. function RemoveRecords($webURL,$listTitle)
  3. {
  4. $web = Get-SPWeb $webURL
  5. $list = $web.Lists[$listTitle]
  6. $items = $list.Items
  7. Write-Host "Start undeclaring..." -ForegroundColor Cyan
  8. foreach($item in $items)
  9. {
  10. $IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
  11. if ($IsRecord -eq $true)
  12. {
  13. Write-Host "Item undeclared" -ForegroundColor Green
  14. [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($Item)
  15. }
  16.  
  17. }
  18. }
  19. RemoveRecords webUrl listTitle

效果:将在指定的web的指定list中批量添加/移除records。

运行效果:

使用方法:

1、将脚本内容中的web Url和listTitle修改成指定的内容后保存到ps1文件,右键run with PowerShell即可;

2、直接调用:

SharePoint自动化系列——Add/Remove "Record" from items的更多相关文章

  1. SharePoint自动化系列——Add/Remove “Hold” from items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题1: 1.如果SharePoint item被添加了hold,通过UI界面来对SharePoi ...

  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自动化系列——通过PowerShell在SharePoint中批量做数据

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

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

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

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

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

随机推荐

  1. Lintcode: Segment Tree Query II

    For an array, we can build a SegmentTree for it, each node stores an extra attribute count to denote ...

  2. ShareSDKForANE 打包笔记

    最近做了一个ShareSDK IOS的接入 (ANE) , 现在想想其实很简单 不过由于对Xcode,ANE的不熟悉也折腾了好久, 舔着脸打扰客服好几天… 呵呵 目前把我接入的一些步骤列出来 希望能帮 ...

  3. Facebook Hacker Cup 2014 Qualification Round

    2014 Qualification Round Solutions 2013年11月25日下午 1:34 ...最简单的一题又有bug...自以为是真是很厉害! 1. Square Detector ...

  4. using 名称空间指定一个别名

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. 封装upload文件上传类

    <?php //封装php中的单文件(图片)上传类 /*  //参数1:$file 文件数组  5个属性值 name,type,size,tmp,error   //参数2:文件保存的路径$pa ...

  6. yii2封装一个类控制div宽度,高度

    1.首先,封装一个类,放在文件夹vendor下,命名为articls.php. <?phpclass Articles{ //测试    function add()    {        r ...

  7. struts_19_对Action中所有方法、某一个方法进行输入校验(手工编写代码实现输入校验)

    对所有方法进行校验1.通过手工编写代码的形式实现 需求:用户名:不能为空手机号:不能为空,并且要符合手机号的格式1,3/5/8,后面是9个数字 第01步:导包 第02步:配置web.xml <? ...

  8. 弱类型变量原理探究(转载 http://www.csdn.net/article/2014-09-15/2821685-exploring-of-the-php)

    N首页> 云计算 [问底]王帅:深入PHP内核(一)——弱类型变量原理探究 发表于2014-09-19 09:00| 13055次阅读| 来源CSDN| 36 条评论| 作者王帅 问底PHP王帅 ...

  9. Win2008 IIS7日期时间格式更改最简便方法

    windows2008 这么高级的系统不可能改个系统的日期时间显示格式还要进注册表啊.于是有baidu,google了下终于发现了,原来还有不需要注册表的更简便方法. windows2008默认时间格 ...

  10. Linux centOS7 下安装mysql5.7.10

    1:下载二进制安装包 http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz 2:解压到 ...