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 ...
随机推荐
- c++之路进阶——codevs4543(普通平衡树)
4543 普通平衡树 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 这是一道水题 顺便祝愿LEZ和ZQQ 省 ...
- SpringMvc的数据绑定流程
在SpringMvc中会将来自web页面的请求和响应数据与controller中对应的处理方法的入参进行绑定,即数据绑定.流程如下: -1.SpringMvc主框架将ServletRequest对象及 ...
- CCF真题之数列分段
201509-1 数列分段 问题描述 给定一个整数数列,数列中连续相同的最长整数序列算成一段,问数列中共有多少段? 输入格式 输入的第一行包含一个整数n,表示数列中整数的个数. 第二行包含n个整数a ...
- ajax“显示弹窗详情”和“删除”功能练习
1.查看详细信息,以弹窗的形式显示,使用ajax 2.批量删除 “查询”功能可以参考前面的文章,这里只讲解ajax“显示弹窗详情”和“删除”功能 第一:在body中的代码 <title>a ...
- SQL数据库之变量
--学习SQL数据库,变量是必须要掌握的概念,系统变量就是变量中最重要的变量之一,下面是SQL中系统变量的应用实例 use AdventureWorksDW exec sp_addtype 'char ...
- 学点儿c#语言wpf开发
首发:个人博客,更新&纠错&回复 visual studio 2015,界面越来越漂亮了. 比起swift和python啥的,还是c#外观上更像java,windows的界面编程,wp ...
- python时间处理函数
所有日期.时间的api都在datetime模块内. 1. 日期输出格式化 datetime => string import datetime now = datetime.datetime.n ...
- 分享总结:更好地CodeReview
代码质量分享 2016_06_24_舒琴_代码质量.key For 代码提交人 基本原则 Review时机: 对于普通bugfix或优化,CodeReview最迟要 ...
- linux设备驱动归纳总结(四):1.进程管理的相关概念【转】
本文转载自;http://blog.chinaunix.net/uid-25014876-id-64866.html linux设备驱动归纳总结(四):1.进程管理的相关概念 xxxxxxxxxxxx ...
- 自动封装Servlet HttpServletRequest请求成为一个POJO对象
自己写了个小工具类,将Servlet里面的HttpServletRequest请求封装成为一个POJO对象,可以复习一下Java的反射原理,开发中这个没什么用,毕竟都用MVC框架,框架都自带这种功能, ...