Thursday, March 9, 2017

SharePoint - Move List or Library to another site using PowerShell

The Powershell command Export-SPWeb and Import-SPWeb can be used to move the lists or library across sites retaining the Version History, Permissions etc.

This option comes in handy when the list or library size in huge and you cannot save it as template or the Content and Structure feature is not helpful in retaining the versions or some metadata associated.

Sample script to move a list or library is given below

Export-SPWeb -Identity -Path "E:\temp.cmp" -ItemUrl -IncludeVersions All -IncludeUserSecurity

Import-SPWeb -Identity -Path "E:\temp.cmp" -IncludeUserSecurity

here ItemUrl - should be in the format /managedpath/sitename/lists/listname or /managedpath/sitename/libraryname
Example:
/sites/sitename/lists/contacts or /sites/sitename/Documents

More details and options can be found here
https://technet.microsoft.com/en-us/library/ff607895.aspx

https://technet.microsoft.com/en-us/library/ff607613.aspx