views:

177

answers:

0

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 PoSh 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.