zoukankan      html  css  js  c++  java
  • 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、直接调用:

  • 相关阅读:
    实例化讲解RunLoop---IOS
    IOS中的SpringBoard
    Mac版OBS设置详解
    Swift学习Tip之Closures
    Swift中Array的Map
    IOS中的国际化(一)
    IOS,中获取系统内存占有率的方法
    IOS获取两个日期之间的时间间隔
    IOS中微信支、支付宝支付详解
    IOS中的正则表达式:NSRegularExpression
  • 原文地址:https://www.cnblogs.com/LanTianYou/p/5036549.html
Copyright © 2011-2022 走看看