As I previously wrote when trying to find Document Libraries, sometimes you have to find sites and sub-sites in SharePoint without direct access to Central Admin, SQL, or PowerShell. Linked together with that issue, I needed to locate all of the sites and sub-sites that users had created then locate the document libraries that had been created in those sites.

Having created a function to list the libraries, we need a way to find all of the sub-sites branching beneath a given site. So what is our call to just get a listing of sites? If you reference SPService’s wiki you will see there are a series of methods for working with Web objects. What you will find is that there are two options GetWebCollection and GetAllSubWebCollection. The difference is, do you want all sub-sites of the current site you are on, or do you want every sub-site no matter how far down the rabbit hole they are? If you only want the current level then use GetWebCollection, if you want everything use GetAllSubWebCollection.

Here is the simple example to get only the sub-sites of a site.


Let’s expand on this and pull in our code from my last post to find every document library on every sub-site.

So just add in some CSS to make your output look nice, and you have a quick and dirty dynamic report of all user created document libraries all the way down the site structure.

Like this post? Share it!