How to: Archive items in SharePoint

Today I already explained how to clone a SharePoint list using a SharePoint power shell script. I used this script to create archive lists.

Now I want to create a workflow to archive items after a certain time period. This is what I did:

Create a calculated date time column “Archive Date”

In my case I want to move the items to the archive after 2 years.

Create calculated date column

Create a workflow that waits until the archive date and then moves the item to the archive list

Create calculated date column

Configure the workflow to start automatically when an item is created.

To start the workflow for existing items, I also used the following SharePoint power shell script:

# get web
$web = Get-SPWeb http://yoursite
# get list
$list = $web.Lists["Your list"]
# get workflow assiciation
$wa = $list.WorkflowAssociations.GetAssociationByName("Archive", [System.Globalization.CultureInfo]::CurrentCulture);
# start the workflow for each item
ForEach($i in $($list.Items)){
    $web.Site.WorkflowManager.StartWorkflow($i, $wa, $wa.AssociationData, [Microsoft.SharePoint.Workflow.SPWorkflowRunOptions]::Synchronous)
}
# get web
$web = Get-SPWeb http://yoursite
# get list
$list = $web.Lists["Your list"]
# get workflow assiciation
$wa = $list.WorkflowAssociations.GetAssociationByName("Archive", [System.Globalization.CultureInfo]::CurrentCulture);
# start the workflow for each item
ForEach($i in $($list.Items)){
    $web.Site.WorkflowManager.StartWorkflow($i, $wa, $wa.AssociationData, [Microsoft.SharePoint.Workflow.SPWorkflowRunOptions]::Synchronous)
}