SharePoint自动化系列——Add/Remove "Record" from items
转载请注明出自天外归云的博客园: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的更多相关文章
- SharePoint自动化系列——Add/Remove “Hold” from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题1: 1.如果SharePoint item被添加了hold,通过UI界面来对SharePoi ...
- 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自动化系列——通过PowerShell在SharePoint中批量做数据
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...
- SharePoint自动化系列——创建MMS terms
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...
- SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...
随机推荐
- Leetcode: Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- 转:Jmeter之Bean shell使用(一)
一.什么是Bean Shell BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法; BeanShell是一种松散类型的脚本语言(这点和JS类似); BeanS ...
- oracle 内外连接,左连接,右连接 区别
首先讲解一下 on 与where后面接的条件的区别 on和where条件的区别如下:1. on条件是在生成临时表时使用的条件,它不管on中的条件是否为真,都会返回左边表中的记录.2.where条件是在 ...
- so baby come on~~
http://www.cnblogs.com/mfryf/archive/2013/05/17/3083895.html
- mldn android
ed2k://|file|%E9%AD%94%E4%B9%90%E7%A7%91%E6%8A%80_Android%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98%E7%BB% ...
- 封装,策略模式,Asp换脸
1.简单封装 1>计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text ...
- C#委托实例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace we ...
- ajax中网页传输(三)XML——下拉列表显示练习
XML:页面之间传递数据,跨平台传递 HTML:超文本标记语言,核心标签 XML的形势为 <xml version='1.0'> <Nation> <one> &l ...
- 深入了解webservice_开发实战篇
服务器端: 第一: 配置环境 创建一个Web Project,将XFire自己的包及其XFire依赖的jar包(6个jar包)全部导入到classpath下,方法是,只需将jar包粘贴在WebRoot ...
- some software that is used to speed up your system
1.RAMDISK take some space in ram and use them as the disk. Primo Ramdisk Server Edition 5.6.0 regist ...