unable to set retention policy for sharepoint content type using sharepoint poweshell + RRS feed

  • Question

  • Hello every one.

    I ma using sharepoint 2010, and management shell. i am trying to  set a retention policy(Declared) based on modified + 2 days , Policy set is working as expected but the documents under that content type is not Declaring.  below is the code.

    $policyxml = "<Schedules nextStageId='2'>"+
                "<Schedule type='Default'>"+
                        "<data stageId='1'>"+
                            "<formula id='Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Formula.BuiltIn'>"+
                            "<action type='action' id='Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Action.Record' />"+
    $policyfeatureID = [Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration]

    $webapp = get-spwebapplication "Insight Portal"
    #********Moved this out of the loops since it only needs to be declared once
    $parentCtypes = @("Custom contenttype1","Custom contenttype2");

    $SiteStatus = Import-Csv -Path '.\input.csv' 

    foreach ($site in ($sitestatus | ?{$_.Status -ne "Success"})) 
        $spsite = get-spsite $site.url
        # Get the SubSites/Webs in the Site Collection
        foreach($spWeb in $SPsite.AllWebs) 
            Write-Host 'Web Site:' $spWeb.URL
            #Fill the array with base content types i.e. Exelon Content Page
    #********Instead of looping through all the content types, only grabbing the ones we want to update
            $ctypes = $spweb.contenttypes | ?{$parentCtypes -contains $_.name}
            foreach($ctype in $ctypes | ?{$_.name -ne $null})
                Write-Host $ctype.Name -ForegroundColor Magenta
                $ctypePolicy = [Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::GetPolicy($ctype);
                if($ctypePolicy -ne $null)
                    foreach($item in $ctypepolicy.Items)
                [Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::CreatePolicy($ctype, $null)
                $ctypePolicy = [Microsoft.Office.RecordsManagement.InformationPolicy.Policy]::GetPolicy($ctype);
                Write-Host "The Policy For" $ctype.Name "Has Been Created And Applied!" -ForegroundColor Green 

        $site.status = "Success"
        $SiteStatus | export-csv '.\input.csv' 


    Friday, May 10, 2019 11:34 AM