如何获取sharepoint列表保留策略说明

时间:2012-05-31 17:41:14

标签: sharepoint

Microsoft.Office.RecordsManagement.InformationPolicy.ListPolicySettings API提供了一种为列表设置保留策略的方法:

public void SetRetentionSchedule(string retentionXml, string description)

有GetRetentionSchedule方法,它返回retentionXml。如何取回说明?

任何建议都将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

这应该让你解决: http://social.technet.microsoft.com/Forums/en-CA/sharepointgeneralprevious/thread/3a7323f6-a3fd-4e2b-9c67-27a1fc18c1c4

这是一个powershell版本:

function Get-RetentionScheduleDescriptionForFolder() {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [Microsoft.SharePoint.SPList]$List
    )
    $policyFile = $List.ParentWeb.GetFile(( Join-Uri list.RootFolder.Url "Forms/RetentionPolicy.Xml"));
    if ($null -ne $policyFile) {
        [xml]$xml = (New-Object System.Text.UTF8Encoding).GetString($policyFile.OpenBinary());
        $xml.RetentionItems.a.Desc;
    } 
}

function Join-Uri () {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Path,
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$ChildPath )
    $scheme = (([System.Uri]$Path).Scheme)+'://'
    if($scheme -ne '://') {
        $joinedPath = Join-Path -Path $Path.Replace($scheme, '') -ChildPath $ChildPath
        $scheme+($joinedPath.Replace('\', '/'));
    } else {
        $joinedPath = Join-Path -Path $Path -ChildPath $ChildPath
        $joinedPath.Replace('\', '/');
    }
}