Advertisement
private775

[PS] SharePoint - Approve all documents in document library

Sep 14th, 2018
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-PSSnapin "Microsoft.SharePoint.PowerShell"
  2.  
  3. $webUrl = "http://acme.com/web/"
  4. $listtName = "Documents"
  5.  
  6. $w = get-spweb $webUrl
  7. $l = $w.Lists.TryGetList($listtName)
  8.  
  9. $spQuery = New-Object Microsoft.SharePoint.SPQuery
  10. $spQuery.ViewAttributes = "Scope='Recursive'";
  11. $spQuery.RowLimit = 2000
  12. $caml = "<Where><Neq><FieldRef Name='_ModerationStatus'/><Value Type='ModStat'>0</Value></Neq></Where>"
  13. $spQuery.Query = $caml
  14.  
  15. $ii = $l.GetItems($spQuery)
  16.  
  17. $ii|%{$_.File.Approve('Automatically Approved')}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement