Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Iterate Through Lists Instead of Document Libraries, Or both

$
0
0

System Info: SharePoint 2010 Enterprise w DEC 2013 CU. 2 WFEs (load balanced), App Server, SSRS Server, Dedicated CA Server (All running Win 2k8 R2).

Background:I have a large (5,000 user) application that is completely customized on top of SP2010. I am the admin, and have been on the team for many years. Previously, we had a development team, but client has scaled costs back, and now its just me on the technical side. We have a Web app that houses multiple Site Collections, and each site collection has various subsites.

My Problem: We have increased the LVT to 10k items (system has plenty of HP, although we do see performance degradation). Each subsite in the Site Collection holds data specific to an organization wtihin the Line of Business. There are two lists that frequently approach the 10k mark, and we have mitigation steps in place (essentially, we just create a new SubSite for them once they reach 10k). What I need is a single script that will traverse ALL subsites and return a count of their lists, perhaps I can work a couple of if statements in there to have specific data written to a SP List (if count is greater than 5000), and other wise everything gets written to the output file.

I am trying to iterate through all lists and return a count of folders + items ... The script below works just fine, but it goes through Document Libraries only (per the baseType eq tag). I've tried changing baseType from DocumentLibrary to GenericList, but I continually get an error.

I've also removed the where baseType = DocLib clause completely, and this has the desired results (all lists and doclibs are listed), except the 'WebUrl' field in the csv output is blank.

Any thoughts on how I can make a small tweak to this script to get my desired results?

Start-SPAssignment -Global
$OutputFile ="D:\folder\DocCount3.csv"
$results = @()
$webApps = Get-SPWebApplication http://WebAppURL
foreach($webApp in $webApps)
{
    foreach($siteColl in $webApp.Sites)
    {
        foreach($web in $siteColl.AllWebs)
        {
            $webUrl = $web.url
            $docLibs = $web.Lists | Where-Object {$_.baseType -eq "DocumentLibrary"}
            $docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
            $results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
        }
    }
}
$results | Export-Csv -Path $OutputFile -NoTypeInformation
Stop-SPAssignment –Global


Viewing all articles
Browse latest Browse all 11571

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>