Using PowerShell to Approve List Items
During the long and painful process of transferring this blog from SharePoint 2007 to SharePoint 2010, I came across a couple of annoying problems. Fortunately, the most annoying problem was quite easy to solve. When I copied the old list items over, they showed up in the new list with an approval status of "Pending", preventing them from showing up on the main blog page and in theRSS feed. Ok, not a big deal, but I’ve got hundreds of blog posts going back several years – I sure wasn’t going to go through and approve everything manually. This is where PowerShell comes in *real* handy. A quick script and I was back in business. Here it is in case you ever find yourself in the same situation:
$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()
}
Simple but effective. The script just loops through the target list and sets the Approval Status field (note that the internal name is "_ModerationStatus") to a value of zero, which in SharePoint-speak means "Approved".
I love simple solutions to simple problems 🙂
great work – thanks for the tip!
This is awesome. Thank you very much. My only question is how would you do this so that both files and folders get approved? I ran the script above (modified for my environment) and all files got approved but the folders did not.
Interesting post and thanks for sharing. Some things in here I have not thought about before, This blog has given me opportunity to learn many things regarding products and services.
http://www.fprinting.com/custom-vinyl-decals-for-cars/
Thanks Buddy for sharing the information. Saved me a lot of headache.
That worked great11
I just want to get a report of all list items across my site collection that are in a pending state. Most scripts I am finding are for documents, not list items like announcements, events. And I need it across the site collection, not on a specific list. Can you help with that?
Thanks for sharing. It worked as charm.
Thanks for share, helps me a lot