private775 icon

[PS] SharePoint - Approve all documents in document library

private775 | PRO | 09/14/18 09:56:34 AM UTC | 0 ⭐ | 887 👁️ | Never ⏰ | []
PowerShell |

500 B

|

None

|

0 👍

/

0 👎

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