none
Copy Documents between Sharepoint 2010 Libraries RRS feed

  • Вопрос

  • I'm trying to copy files from one Sharepoint 2010 document library to another in the same site

    $web = get-spweb "someurl"

    $list = $web.lists["Plans"]

    $items = $list.items

    foreach($i in $items) {  $i.copyto("https://siteurl/PlanArchive")   }

    Everytime it errors out with the following:

    Exception calling "CopyTo" with "1" argument(s): "Cannot create an item at the requested destination.  Verify that the folder exists and that y
    ou have permission to edit in it."
    At C:\Users\joekeohan\AppData\Local\Temp\2\709b5c3f-aa7a-43c4-9a14-711c957b37e6.ps1:11 char:11
    +     $i.CopyTo <<<< ("https://bcmportal.com/PlanArchive")
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    I've verified I can create new items in the library and that the url is correct.  

    The CopyTo method uses the following overload:  String destinationUrl

    Any ideas?

    Joe

    31 августа 2012 г. 19:43

Ответы

  •  So I decided to create a new list with 1 folder and several documents. It does look like I'll need to recursively enumerate through $Web.GetFolder as it see's only top level files. 

    $web = Get-SPWeb https://portal.com
    $list = $web.Lists["Test"]
    $items = $list.Items
    $Folder = $web.GetFolder("Test")
    $Files = $folder.Files
    $items | select name,url 
    "#################"
    $Files | select name,url

    Name                                    Url                                   
    ----                                    ---                                   
    Doc1.txt                                test/Fol1/Doc1.txt                    
    Doc1.txt                                test/Doc1.txt                         
    Doc2.txt                                test/Doc2.txt                         
    #################
    Doc2.txt                                test/Doc2.txt                         
    Doc1.txt                                test/Doc1.txt   

    • Помечено в качестве ответа Yan Li_Moderator 14 сентября 2012 г. 2:57
    10 сентября 2012 г. 13:01

Все ответы