Run STSADM commands from SAF

I am pleased to announce that it’s now possible (with release 1.2.3463.00) , to run STSADM commands from the SharePoint Action Framework (SAF). Hence, if you add the standard STSAdm commands (that ship with SharePoint) to the truly awesome collection that Gary Lapointe has developed, (available on his STSADM Blog), you are looking at over 250 useful SharePoint Actions.

This functionality has been made available by a new Action called “StsAdm”. The Action should be called via an Alias like this “Action.StsAdmin”. (Aliasing is for convenience so that you don’t have to put the full 4 part assembly reference into the Macro).

An example :

This example illustrates how to create a Macro that calls the new Action and executes 2 STSAdm commands to delete a group and also create the group.

The StsAdmin Action

As can be seen from the example above, it’s pretty straight forward to use the StsAdmin command. You use the Action by adding this line :

<object name=RunStsAdminCommandstype=Action.StsAdmin>
<
property name=EntityListref=StsAdminCommandList
/>
<
property name=StopOnDoExceptionvalue=false
/>
< /
object>

The StsAdminCommand Entity

As with every Action, all of the parameter information is passed into the Action via a simple Entity. The Entity in this case is called “Entity.StsAdminCommand”. This entity has 2 properties that need to be passed, the Operation and the Arguments. Please Note! It’s possible to supply as many entities as you like. These will all get executed as separate STSAdm commands.

By supplying the Action (with its entity) this is equivalent to writing :

STSADM -o deletegroup -url http://localhost -name -“SAF Demo Group”.

Note! The “${CurrentWeb.Url}” line, shown in the example, is called a Placeholder and will substitute the value with real “url” at runtime.

That’s pretty much it. You can now call any STSAdm command available by supplying a correct “Operation” and dictionary matching the parameters that the command takes.

Download SAF from http://SAF.Codeplex.com.