[PS] SharePoint - Approve all documents in document library
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$webUrl = "http://acme.com/web/"
$listtName = "Documents"
$w = get-spweb $webUrl
$l = $w.Lists.TryGetList($listtName)
$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.ViewAttributes = "Scope='Recursive'";
$spQuery.RowLimit = 2000
$caml = "<Where><Neq><FieldRef Name='_ModerationStatus'/><Value Type='ModStat'>0</Value></Neq></Where>"
$spQuery.Query = $caml
$ii = $l.GetItems($spQuery)
$ii|%{$_.File.Approve('Automatically Approved')}
Comments