SharePoint 2013 | Approve a list item | PowerShell

From here: https://sharepoint-learners.blogspot.com/2016/09/sharepoint-2013-approve-list-item.html

Work Statement: Approve all the list items
 
$site = new-object Microsoft.SharePoint.SPSite("http://site")
$web = $site.OpenWeb()
$list = $web.Lists["Posts"]
$items = $list.Items

foreach ($item in $items)
{
    $item["_ModerationStatus"] = 0
    $item.Update()
}



Work Statement: You want to approve a single list item

$site = new-object Microsoft.SharePoint.SPSite("http://site")
$web = $site.OpenWeb()
$list = $web.Lists["Posts"]
$items = $list.GetItemById(10)
$item["_ModerationStatus"] = 0

$item.Update()


The following are more ModertionStatus:

ValueDescription
0 The list item is approved.
1 The list item has been denied approval.
2 The list item is pending approval.
3 The list item is in the draft or checked out state.
4 The list item is scheduled for automatic approval at a future date.