Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to create a list of all subsites (all levels), and some details about each of them. The simplest way is to do a recursive function, but I have many subsite (about 600) and I want a more efficient way.

Is SPSiteDataQuery may be appropriate in such a case?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

I haven't used SPSiteDataQuery, but I have used PowerShell to return a list of all subsites from a SharePoint Web Application (it returns the title, url, and id of each) and saves it to a CSV file:

Get-SPWebApplication "http://webappname/" | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID | Export-CSV C:\IterateAllSitesSubsites.ps1.csv -NoTypeInformation

share|improve this answer
    
It works. Do you know if there is corresponding code in C#? –  banana Oct 11 '12 at 7:48
1  
I found this link which explains how to find this information using C#. Also, this article from MSDN might help. –  ajbillin85 Oct 11 '12 at 15:41
add comment

I researched a way to do this before. In my case I needed to get a list of all sites across all site collections and even between multiple farms. I ended up creating my own timer job that ran every hour to update a database where I stored the structure. Also, every evening I ran another timer job to store in a different table who has access to read what site. That way I can easily create a "my team sites" webpart which quickly displays all of the sites a user has access to. With this setup and some column indexing I was able to get my webpart to run in under 2 seconds and sometimes displaying thousands of team sites.

share|improve this answer
    
It's a good idea, but does not exactly fit my needs. Thanks anyway. –  banana Oct 11 '12 at 7:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.