A while back, I wrote about my philosophy on using SharePoint tools, and how I preferred to create my own tools. A total of 1 reader wrote to me at furuknapgmail.com and asked if I could provide some examples. Don’t say I do not listen to your comments and emails, so I’m going to post some sample SharePoint tools that I have made and use on a very regular basis. The first tool is the SPSiteLister I mentioned.
First, check out the article on how to add SPDisposeCheck to the Tools menu of Visual Studio. As the comments revealed, however, I was too lazy and didn’t bother Googling first, which would have revealed that there were already several articles describing this. And no, I didn’t make SPDisposeCheck. However, the technique of adding tools to Visual Studio is very important.
The other tool I mentioned in the tools philosophy article was a tool to list sites and web applications in a farm. I call this the SPSiteLister, and I keep it as an external tool as well. Since I work on many projects at a time, or at least, need access to multiple sites in my lab, I want to list all the web applications and the root webs so that I know which site I want. Here’s the output from that tool:
This tool is very simple to create, but is a perfect example of the ‘create a tool when you need it’ philosophy. You may not need just this tool, but I do, which is why I made it, and it has saved me tons of time.
To make this tool, you can follow these steps:
- Create a new Console Application in Visual Studio
- Add references to Microsoft.SharePoint.dll
- Add the following two using-statements:
- Add the following code inside your Main method:
SPFarm farm = SPFarm.Local;
SPWebService webService = farm.Services.GetValue(“”);
foreach (SPWebApplication webApp in webService.WebApplications)
using (SPSite site = webApp.Sites)
using (SPWeb rootWeb = site.RootWeb)
Console.WriteLine(webApp.DisplayName + ” | ” + site.Url + ” | ” + rootWeb.Title);
- Compile and add the resulting .exe as an external tool in Visual Studio.
When making these tools, I add the external tool directly to the build-folder of my Visual Studio project. That way, if I need to change the tool in any way, I can simply make the changes, compile, and the new tool is available immediately. When I move to other development lab environments, I bring the entire Visual Studio project for the tool to the new lab.
I think I’ll post more info on other tools I’m using in later posts, which may or may not benefit you, but at least may give you inspiration to start thinking about creating your own toolset.
Found this article valuable? Want to show your appreciation? Here are some options:
a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.
b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.
c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!