SharePoint自动化系列——Add/Remove Record from items
生活随笔
收集整理的這篇文章主要介紹了
SharePoint自动化系列——Add/Remove Record from items
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
轉(zhuǎn)載請注明出自天外歸云的博客園: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.ItemsWrite-Host "Start declaring..." -ForegroundColor Cyanforeach($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 listTitle2.Remove records(這個用處比較大,尤其items較多時,在SharePoint中移除records是非常麻煩的事):
Add-PSSnapin Microsoft.SharePoint.PowerShell function RemoveRecords($webURL,$listTitle) {$web = Get-SPWeb $webURL $list = $web.Lists[$listTitle]$items = $list.ItemsWrite-Host "Start undeclaring..." -ForegroundColor Cyanforeach($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。
運(yùn)行效果:
使用方法:
1、將腳本內(nèi)容中的web Url和listTitle修改成指定的內(nèi)容后保存到ps1文件,右鍵run with PowerShell即可;
2、直接調(diào)用:
總結(jié)
以上是生活随笔為你收集整理的SharePoint自动化系列——Add/Remove Record from items的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Datatable删除行的Delete和
- 下一篇: IBM收购Clearleap,提供云视频