日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharePoint自动化系列——Add/Remove Record from items

發(fā)布時間:2025/3/20 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 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.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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。