Friday, August 15, 2014

Approve items in Sharepoint list using powershell script

Approve items in SharePoint list using powershell script in one go

Copy below code in notepad and save it as ps1 and run it

$spSite = new-object Microsoft.SharePoint.SPSite("WebapplicationURL")

Write-Host "Updating SharePoint list"
$spWeb = $spSite.OpenWeb("Subsitename")
$spList = $spWeb.Lists["Listname"]
$spitems = $splist.items
foreach($item in $spitems) {
$item["_ModerationStatus"] = 0;
 $item.Update();
}

Write-Host "Completed...."

Open SharePoint Powershell command and run file as approve.ps1

c:>.\approve.ps1

Check your SharePoint list or library an

No comments:

Post a Comment