Client-Side script to upload attachments to the Sharepoint 2007 list
Posted
by Clone of Anton Makrushin
on Stack Overflow
See other posts from Stack Overflow
or by Clone of Anton Makrushin
Published on 2010-03-17T01:08:18Z
Indexed on
2010/03/17
1:11 UTC
Read the original article
Hit count: 715
Hello.
I have no good script-writing experience.
So, I have a list created on MOSS 2007 with about 1000 elements and attachments enabled. I need to attach to each list item file (*.jpg) from a local folder. I doesn't have administrator privileges at MOSS server, only contributor rights
Here is my script:
$web = new-Object system.Net.WebClient
$web.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$web.Headers.Add("user-agent", "PowerShell Script")
$web.UploadFile('http://ruglbsrvsps/IT/Lists/Test1/', 'C:\temp\Attachments\14\Img1.jpg' )
Test1 - target list; Item1, Item2, Item3 - list items, without attachments, created manually
When I run script, it returns byte array and does not upload file to the list item.
Can you fix my script or advice better solution for my task (attach bulk of files to the MOSS list items, only contributor rights for target Sharepoint 2007 list)
Thank you.
© Stack Overflow or respective owner