I am trying to delete all items from my Document Library using PowerShell using the below code. But its not deleting the checked out items from the Document Library.
How to delete the checkedout items along with checkedin items from document library.
Add-PSSnapin -Name Microsoft.Sharepoint.Powershell
write-host "continuing"
$web = get-SPWeb "http://sirvr:123/sites/OnM/"
$DocLibsName = "CBM-SE"
$list = $web.lists | where { $_.title -eq $DocLibsName }
Write-host "List $($list.title) has $($list.items.count) entries"
$items = $list.items
foreach ($item in $items)
{
$item.CheckIn("Checked In By Administrator")
#To publish a file:
$item.Publish("Automatically published by Powershell")
#To approve a file:
$item.Approve("Automatically approved by by Powershell");
Write-host " item is approved..."
$list.getitembyid($Item.id).Delete()
Write-host " item is deleted successfully..."
}