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

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

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

 Add-PSSnapin Microsoft.SharePoint.PowerShell
function AddRecords($webURL,$listTitle)
{
$web = Get-SPWeb $webURL
$list = $web.Lists[$listTitle]
$items = $list.Items
Write-Host "Start declaring..." -ForegroundColor Cyan
foreach($item in $items)
{
$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
if ($IsRecord -eq $false)
{
Write-Host "Item declared" -ForegroundColor Green
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::DeclareItemAsRecord($Item)
} }
}
AddRecords webUrl listTitle

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

Add-PSSnapin Microsoft.SharePoint.PowerShell
function RemoveRecords($webURL,$listTitle)
{
$web = Get-SPWeb $webURL
$list = $web.Lists[$listTitle]
$items = $list.Items
Write-Host "Start undeclaring..." -ForegroundColor Cyan
foreach($item in $items)
{
$IsRecord = [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::IsRecord($Item)
if ($IsRecord -eq $true)
{
Write-Host "Item undeclared" -ForegroundColor Green
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::UndeclareItemAsRecord($Item)
} }
}
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. HDU 1890 区间反转

    http://acm.hdu.edu.cn/showproblem.php?pid=1890 Robotic Sort Problem Description Somewhere deep in th ...

  2. [Reprint]c++中typename和class的区别介绍

    在c++Template中,很多地方都用到了typename与class这两个关键字,而且好像可以替换,是不是这两个关键字完全一样呢?   相信学习C++的人对class这个关键字都非常明白,clas ...

  3. csuoj 1329: 一行盒子

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1329 1329: 一行盒子 Time Limit: 1 Sec  Memory Limit: 12 ...

  4. Python高频技巧总结[基础篇]

    0. 概要说明 python应用最多的场景还是web快速开发.爬虫.自动化运维:简单网站.自动Fuzz脚本.收发邮件脚本.简单验证码识别脚本. 爬虫在开发过程中也有很多复用的过程,这里总结一下,以后也 ...

  5. GitHub和SourceTree入门教程——(转载),希望能帮到有需要的人

    -->本教程适用于主流的开源网站github和bitbucket,个人认为sourceTree还是比较好用的git客户端,支持windows和mac os. -->soureceTree的 ...

  6. Struts2部署在Websphere上的问题

    配置Mapped Filter:可以解决Struts2的项目部署在WebSphere6.1下面,发生Action找不到的情况. 应用程序服务器>[选择所使用的服务器]>Web 容器设置&g ...

  7. java 网络编程(二)----UDP基础级的示例

    下面介绍UDP基础级的代码示例: 首先了解创建UDP传输的发送端的思路: 1.创建UDP的Socket服务.2.将要发送的数据封装到数据包中.3.通过UDP的socket服务将数据包发送出去.4.关闭 ...

  8. [tp3.2.1]数据模型 - 简单的模型连接

    新建数据库数据库连接功能    1.写conf.php        /* 数据库设置 */        'DB_TYPE'               =>  '',     // 数据库类 ...

  9. centos 7 systemctl

    Linux Systemctl是一个系统管理守护进程.工具和库的集合,用于取代System V.service和chkconfig命令,初始进程主要负责控制systemd系统和服务管理器.通过Syst ...

  10. linux设备驱动归纳总结(五):4.写个简单的LED驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-84693.html linux设备驱动归纳总结(五):4.写个简单的LED驱动 xxxxxxxxxxx ...