Below is the
Powershell script to delete document by Name from Document Library
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object
Microsoft.SharePoint.SPSite("http:// sharepoint-site-url ")
$web = $site.openweb()
$list=$web.Lists["Document-Library-Name
"]
$listItems = $list.Items
$listItemsTotal = $listItems.Count
Write-Host $listItemsTotal
for ($x=$listItemsTotal-1;$x -ge 0;
$x--)
{
if($listItems[$x].name.Contains("file"))
# file refers to the name of the document
{
Write-Host("DELETED: " +
$listItems[$x].name)
$listItems[$x].Delete()
}
}
Hi There,
ReplyDeleteThis script doesn't seem to work. No errors are reported at all.
Thanks,
Steven
Its works for me ! ? Thanks for the script !
ReplyDeleteIts worked for me thanks !
ReplyDelete