mandag den 15. juli 2013

Count all documents in SharePoint 2010 with powershell

Runs trough sharepoint and counts all items in "Documents" library.

cls

$total = 0
$totalembers = 0;

foreach($site in Get-SPSite -Limit all)
{
    foreach($web in $site.AllWebs)
    {
        $totalembers = $totalembers + 1
       
        $list = $web.Lists["Documents"];
       
        $listCount = $list.ItemCount
        #$listCount = $list.Item.Count #more accurate but slow
       
        $total = $total + $list.ItemCount
        echo $web
        echo $total
    }
}

$logMsg = "Total Members " + $totalembers + "; Total Documents " + $total + ";"
write $logMsg

Ingen kommentarer:

Send en kommentar