Forum Discussion

Martin Segelfeldt's avatar
Martin Segelfeldt
Copper Contributor
Mar 16, 2017

Moving files between sites (PowerShell & JavaScript)

I need to move a file between two sites, the soruce is a sub site of ther target site. The https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/MovePnPFile.md  seem to support moving between site collections and should there for work when moving between sites?

 

Example:

Source = http://xyz.sharepoint.com/sites/system/subsite/documents/test.txt

Target = http://xyz.sharepoint.com/sites/system/documents/test.txt

 

When i try this i first use Connect-PnPOnline and uses to url to the siter were the documet is located (soruces site).

 

When i use a relative target url i get the following errror.

"Parameter name: Specified value is not supported for the serverRelativeUrl parameter."

 

When i use a absolute target url i get

"URL is not for this web"

 

If i move the document within the same site it works flawlessly, am i missing something? Or is moving files between sites not supported.

 

I know that the server side object model https://msdn.microsoft.com/en-us/library/office/ms468280.aspx only supports moving files withing the same site.

 

I am aware that PnP-JS-Core also have a moveTo implementation but my understanding is that the .NET c#, PowerShell and JavaScript version of PnP calles the same endpoint and i should therefor expect the same result?

 

If MoveTo does not support moving between sites, what is the recommended solution for doing this programmatically, we have a case were this is needed for both front-end and back-end stuff.

No RepliesBe the first to reply

Resources