Why an STSADM Blog?

Posted on Posted in Uncategorized

So this is my first posting to my first blog. I’ve been wanting to start blogging for quite some time now but either haven’t found the time or the inspiration. Lately I’ve been doing a lot of SharePoint work for the company I work for (Edfinancial Services). We are preparing to go from SharePoint Portal Server 2003 to MOSS 2007. For our purposes we’ve decided to do a gradual upgrade. However, our current taxonomy leaves little to be desired and as a result we’ve decided to use this project as a way to rework the site structure and overall taxonomy. Due to the number of changes we are planning on making and the amount of testing and preparation involved I decided that I need my upgrade to be completely scripted (there’s just too many things to miss when making the changes manually). We’ve been “practicing” the upgrade in a virtual environment and using STSADM to script all of our changes. The problem is that STSADM only lets you do so much and most of the things we need it can’t do (particularly SSP customizations such as managing the profile import or My Sites settings).

At first I didn’t realize that you could extend STSADM but when I was searching for a way to manage the profile import jobs I came across an article by Joerg Brunke on Code Project (http://www.codeproject.com/useritems/stsadm_commands.asp). I used the project he created as a starting place to create many more new commands. The majority of these commands are not likely to be helpful to many people unless you find yourself in a similiar position of needing to create a repeatable upgrade script. However, I’ve found that the code itself can be a great way to discover more about the internals of SharePoint and may help others in completing similiar tasks within custom workflows or site definitions or whatever other customization you may need to do within MOSS.

You can download the source files for the project that I’ve been creating here. I plan on blogging about each of the commands as I create them (which means I’ve got some back filling to do as I’ve already created about 25 of them). Note that the namespace reflects the company I work for – feel free to change any part of this project to meet your needs. If you improve any of the commands or add to them please comment here so that I can include them in for others.

For a general overview of how to create STSADM extensions check out Tony Bierman’s article “Extending stsadm.exe with Custom Commands using the ISPStsadmCommand Interface“. The quick answer to how to do this is to simply create a class which implements the ISPStsadmCommand interface, add an xml file to the config hive (c:\program files\common files\microsoft shared\web server extensions\12\config) using the naming convention of stsadmcommands.[something unique].xml and then register your assembly in the GAC. The xml file you create contains the comand name and the class name (fully qualified). The easy part is extending STSADM – the hard part is figuring out how to manipulate SharePoint using the provided object model (which is loosely documented at best). It’s this part that I’ll spend most of my effort blogging about as it’s a nightmare trying to figure some of this stuff out (you have to get really good with tools like Lutz Roeder’s .NET Reflector.

Note that I make no warranties expressed or implied about the code I have written. It has been tested thoroughly in my testing environment and has performed as expected however everyone’s environment is different and there may be things about your environment that are different from mine – I strongly encourage you to read and understand the code before attempting to use in a production environment (at a minimum test in your own virtual environment).