Hi All,
In a
following post we will see about a PowerShell Script which is used to delete
all SharePoint List Items.
Code Snippet:
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)][System.String]$Url,
[Parameter(Mandatory=$true)][System.String]$ListName
)
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell
-ea 0))
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
$Web = Get-SPWeb $Url
$List = $Web.lists[$ListName]
if($List
-eq $null){
Write-Error
"The List cannot be found";return
}
Write-Warning "Deleting
all list items from $($ListName)"
$Items = $List.GetItems()
$Items | ForEach-Object{
$List.GetItemById($_.Id).Delete()
}
$List.Update()
$Web.Dispose()
Write-Host "Job
Done"
You can download the same code from the below link,
Thanks.
Related Post
Migration
- Get CheckedOut Files from SharePoint 2013 and MOSS2007
- PowerShell::Get Content Database Size in SharePoint
- Powershell :: Apply Master Page to all sub sites under site collection
- Remove-SPSite 0x80070003 - Forcely delete Site Collection that cannot be deleted
- Migrate Multiple site(sub sites) using MetaLogix and change the Template in Target
- Issue:The date file "C:\ProgramData\Metalogix\EnvironmentSettings.xml" contains invalid data.Values in that file reset to defaults
List
- Column formatting in modern list view
- List view render using JSLink with Fabric UI
- Get List Field Type using ECMA Script in SP Hosted Apps
- What is the Content Type for Custom List in SharePoint 2013, SharePoint 2010
- Related Items Column in SharePoint 2013
- Bulk Insert/Update/Delete Items from SharePoint List/Library
- Create list in SharePoint 2013 using OOB feature:
- Difference between List Definition , List Template and List Instance
- Create List Definition in SharePoint 2013
- Set List/Library Default Content Type Programatically
- Adding Content Type to List/Library Programatically
- Difference between List and Library in SharePoint
- Adding an Item to the Sharepoint List Programatically
0 comments:
Post a Comment