3

I'm trying to populate my test Library that has columns Mentor and Mentee (both are people picker coolumns).

I want to populate this library with 1000 items. It does not matter if they are duplicates. The main objective is to populate this library with up to or over 1000 entries as fast as possible.

I've added 3 items in the Library. How can I duplicate these same items within the same library up to 1000 times?

Can anyone give me some articles or point me to a PowerShell script that might be able to accomplish the above?

1

3 Answers 3

2

In your local machine, copy the 3 files (you mentioned above) and do Copy & paste (Ctrl +C , Ctrl+ V). This will create new 3 files. Now select all 6 files and do Copy Paste. This approach will you will be able to create 1000 files quickly in local machine.

Uploading to SharePoint

  1. If you are using SP 2013 version, you can drag drop all this files in the document library.
  2. Open the document library in IE browser, from library tab open the library in Explorer. Then copy the files to folder opened in browser.

For updating the metadata : Open the library in quick edit mode, add metadata for 1st item, drop drop for remaining items. Save.

2
#Get the item you want to add:
$item = Get-Item "C:\temp\some-file.txt"
#Get the web
$web = Get-SPWeb http://someweb
#get the user. You could get multiple put them in an array and use Get-Random
$user = $web.EnsureUser("domain\user")
#Get the library
$list = $web.lists.TryGetList("Documents")
if ($list) {
    $folder = $list.rootfolder
    for ($i = 0; $i -le 1000; $i++) {            
        $file = $folder.Files.Add("my-file$i.txt", $item.OpenRead(), $true)
        #Add the user. 
        $file.Item["YourColumnName"] = $user
        $file.Item.Update()
    }
}
2

Try this script.

#get web
$web = Get-SPWeb http://weburl

#get list
$list = $web.lists["ListName"]

for($i=0; $i -le 1000; $i++)
{
  $newSPListItem = $list.AddItem();
  $newSPListItem["FieldName"] = $web.EnsureUser("domain\user")
  $newSPListItem.update()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.