STSADM in addition to being a swiss army knife of useful little functions is also one of the most frequently used tools in SharePoint deployments. Being the gatekeeper to easy web part deployment has it’s advantages. However, there are limitations that it has and features that it hasn’t implemented. That’s where one of my latest projects comes in.
First, STSADM is very dependent upon access to the SharePoint content database. If you don’t have enough access the tool doesn’t work. This can be worked around, however, in many environments it represents a barrier to easily using STSADM.
Second, although STSADM allows you to add and remove web parts as trusted assemblies on the server — and deploy default property sets (read as “DWP files“) it does not allow you to add or remove web parts from a web part page from the command line.
However, I’ve been working on a tool the “SharePoint Web Part Administrator” (SPWPADM) that solves both of these two limitations. First, it is entirely based on the web service interface to SharePoint. You can run it from your desk, from the server, or anywhere that you can access the SharePoint built-in web services. Second, it’s exclusive function is to manage web parts on web part pages.
It allows you to enumerate the web parts on a page, add new web parts to a page, delete web parts from a page, export web parts from a page, and even to delete closed web parts on a page. Of all of those, perhaps only the last function needs any explanation…
When people “delete” a web part from SharePoint they’re often times just closing it — suppressing the display. The code is actually still running it’s just that people don’t see the results on the page. That’s really not all that great if you’re doing extensive computations to come up with content that will never be displayed. However, the only way to delete a web part is to enter design mode to delete it. The result is most people close web parts without realizing the impact on their server.
The SPWPADM tool will hunt down these closed web parts and actually delete them for you so they’re no longer running.
So, there are two questions you might ask… 1) “Why did you write the tool?” — The primary reason is because I’m working on an article for DevX.com on how to replace the edit control (ListFormWebPart) for a list. To do that you have to add a new web part to the list pages and remove the existing web part. It’s possible to do but certainly kludgy. So I thought the tool would be a nice thing to offer folks as a trial with the article. It’s turned into slightly more than that as I realized other purposes for it, but at heart it’s designed to facilitate management of a web part page from the command line.
2) “So what is it useful for?” — Thus far I’ve used it for two things… First, deleting closed web parts. You would be amazed at how many of them there are in a typical SharePoint implementation. Second, helping to configure site definitions while building/testing them. When I build a site definition I typically have a page that is composed entirely of web part zones. I don’t have a header, I don’t have a footer, nor menus, nor other parts of the page, those functions are represented by web part zones and by web parts. (Yes, I know this is slightly wasteful from a configuration storage perspective — it does, however, make staying supported while making changes much easier.) So I typically make 20 copies of my default page so I can drop in other content as needed. That means adding half a dozen web parts to each page (header, footer, search, global navigation, site navigation, etc.) So I make a batch file that calls the add web part command for each web part. I nest this in a batch file in one that calls it once for each page. It takes a while but eventually the controls are all placed on every page.
So why am I bringing this up? Well, two reasons, I’m ready to let a few people try it out (send me an email and I’ll send you a copy of it along with a license.) Second, I got someone asking about how to lock web parts in place for 50 or so sales guys on a discussion list I watch. It occurred to me it’s possible to put this in a script that runs every night and deletes and then readds the web parts — the net effect of which is forcing them to be on a page since changes, or removal will be removed each day. Not pretty but an idea that would be easy and effective.
So if you’re interested, drop me a line and I’ll get you a beta/trial copy.