Saturday, June 13, 2015

Content Approval: Approve All List Items in Bulk using PowerShell

When content approval is turned-ON, approving items one by one could be hectic. To bulk approve items, We can utilize PowerShell. Here is my PowerShell script to bulk approve items pending for content approval.

This was a huge time savor for me during a migration project.

PowerShell script to approve List items in Bulk:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Site URL and List Name variables
$WebURL="https://portal.crescent.com/sites/ops/"
$ListName="Tasks"

#Get all List Items
$ListItems= (Get-SPWeb $WebURL).Lists[$ListName].Items

#Iterate through each item
foreach($Item in $ListItems)
{
    #Approve Item
    $item["_ModerationStatus"] = "0" #1 to reject
  
    #Update the item
    $item.Update()
}
write-host "Total Items Approved:"$ListItems.Count

This PowerShell script simply loops through all items in the given list and Approves them by setting the Approval Status field (Internal name is "_ModerationStatus").
approve items using powershell



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


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