日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

發布時間:2025/3/20 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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.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。

運行效果:

使用方法:

1、將腳本內容中的web Url和listTitle修改成指定的內容后保存到ps1文件,右鍵run with PowerShell即可;

2、直接調用:

總結

以上是生活随笔為你收集整理的SharePoint自动化系列——Add/Remove Record from items的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。