mardi 27 janvier 2015

Getting error while copying contents from one library to another

I am using below script to iterate through each folder/file in document library.



$source = "http://sitecollection/sites/site/subsite"
$dest = "http://sitecollection/sites/site/subsitearchive"

$sourceLibrary = (Get-SPWeb $source).Folders["Test"]
$destLibrary = (Get-SPWeb $dest).Folders["Test"]
$destFiles = $destLibrary.Files
foreach ($file in $sourceLibrary.Files)
{
$curFile = $file.OpenBinary()
$destURL = $destFiles.Folder.Url + "/" + $file.Name
$destFiles.Add($destURL, $curFile, $true)
}


However, I am getting error: Cannot find an SPWeb object with Id or URL


Aucun commentaire:

Enregistrer un commentaire