Saturday, August 4, 2012

Delete Attachments from SharePoint List Items using Powershell

There is a requirement to delete all the attachments named as "" from a SharePoint List where 100's of list items already created with lot of attachments. 

This requirement can be achieved with either SharePoint Object model or with PowerShell. Here is the script to programmatically delete the attachments based on its name.

$web=Get-SPWeb -identity ""
foreach($item in $List.Items)
        for($i=$item.Attachments.count-1; $i -ge 0; $i--) 
            write-host "File Deleted:" $item.Attachments[$i]

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...