# Move Document Library PowerShell

I am facing problems while trying to move a Document Library from one Subsite to another on a SharePoint 2013 on premise installation.

I want to "move" a document library with powershell from one subsite to another and I also want to keep the Version history of all files.

I found the following script: https://gallery.technet.microsoft.com/office/Copy-all-SharePoint-Files-0999c53f

But the skript only copies the files and so they get a new version history. Is there a way to copy the history of each file too?

best regards Alex

• Have you tried using Export/Import-SPWeb "http://sharepointurl/subsite1" -ItemUrl "lists/MyList" -Path "C:\" -IncludeVersions All -IncludeUserSecurity" ? -IncludeVersions should keep all versions of files, and IncludeUserSecurity keep permissions on list/files – Nico Feb 2 '15 at 9:04
• If that solved your problem, please tell me so I would expand my comment as an answer, or you can do it yourself – Nico Feb 2 '15 at 9:35

## 1 Answer

Please verify that you're using the Export-SPWeb and Import-SPWeb PowerShell cmdlets, with these arguments:

-IncludeVersions All : To keep all files verions
-IncludeUserSecurity : To keep permissions on files

Example :

Import-SPWeb "http://sharepointurl/subsite1" -ItemUrl "lists/MyList" -Path "C:\"  -IncludeVersions All -IncludeUserSecurity


Please replace "sharepointurl/subsite1" by your site url, and "lists/MyList" by your list url.

More informations on these cmdlet on technet : Export-SPWeb / Import-SPWeb