How to create a PowerShell script to move a document within a site collection


Occasionally documents are saved in the incorrect location in the active site e.g. the wrong Document Set or Document Library. To resolve this you need to be able to move content between locations in SharePoint whilst preserving the integrity of the record in RecordPoint.

RecordPoint's supported method for moving content whilst preserving the integrity of the records in RecordPoint is to use Microsoft's Content and Structure tool.

Although this approach does work for most scenarios, the Content and Structure tool does not support:

  • Moving content between Document Sets; or
  • Moving content into Document Sets from a Library.

This article describes an approach using PowerShell and the SharePoint and RecordPoint APIs to move documents to anywhere within the same Site Collection whilst retaining the integrity of the records in RecordPoint.

Important disclaimers

  1. RecordPoint does not support moving Records between Site Collections. Please consult with RecordPoint if your solution may require this functionality.
  2. RecordPoint will audit a Delete during any Move operation. This is because SharePoint performs all Moves as a Copy followed by a Delete.

Assumed knowledge

Although the approach used is relatively straightforward you should be familiar with the use of PowerShell in SharePoint as you may need to adapt this approach to suit the specific circumstances of your environment.

Standard moves

Prerequisite: RecordPoint automatic Submission Workflow ENABLED for the destination Library (Or on the Content Type being moved).

The SharePoint method to use is SPFile.MoveTo("URL").
Where the SPFile is the file you want to move in this example $file and "URL" is the URL of the location to which you want to move the file, in this case $MoveToLocation. So for example your code could be:

$file.MoveTo( $MoveToLocation )

Less standard moves

Prerequisite: RecordPoint automatic Submission Workflow DISABLED for the destination Library (And on the Content Type being moved). This is done so that we can set the move flag before the item is submitted to RecordPoint.

The above method is suitable for any situation where the Unique ID of the item being moved is not going to change. If the Unique ID will change, it may be necessary to flag the item as having been moved so that RecordPoint does not create a duplicate Record. After performing the move, before submitting the item, user the RecordPoint API to flag the item as having been moved.

First, add the RecordPoint Active Site API as follows (Assuming that RecordPoint is installed to the default location on the machine):

Add-Type -Path "C:\Program Files\RecordPoint\SDK\RecordPoint.Active.SI.dll"

Then create a new object for the record engine, in our example, $recordEngine. This accepts two parameters the -typeName which is the RecordPoint namespace and -Identity which is the URL of the SharePoint front end where your document resides. So your code could look something like this:

$recordEngine = new-object -typeName RecordPoint.Active.SI.API.RecordPointEngine -ArgumentList $Identity

Finally, flag the item as having been moved using the record engine. Assuming you've used something like the above code, you should be able to retrieve the list item from its new location as follows:

$web = Get-SPWeb $Identity
$copied = $web.GetListItem("$MoveToLocation")

Then use the record engine to flag the item as having been moved:

Once the item has been flagged as moved, it should be submitted to RecordPoint by either running a RecordPoint Submission Workflow or using the RecordPoint API.


To verify that the script has worked as expected. Check the following:

  • Is the Record Number the same?
  • Has the File Container reference been updated?
  • Is the Encoded Absolute URL for the Record correct?
  • Is there a duplicate item in RecordPoint?
  • Has the original item been removed from SharePoint?


Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk