Freigeben über


Scripting SharePoint

This is really a bit of a "duh" suggestion, but I'll bet you haven't done it yet ;)

SharePoint 2007 has a great scriptable command-line tool called stsadmin.exe, which is used to perform the SharePoint administration tasks at the command line or by using batch files or scripts. It also provides access to operations not available by using the Central Administration site, such as changing the administration port.

Where does it live?

%COMMONPROGRAMFILES%\microsoft shared\web server extensions\12\bin

So... when it comes time to change passwords, merge content databases, etc, you end up typing commands that look like:

c:\progam files\common files\microsoft shared\web server extensions\12\bin\stsadmin.exe -o mergecontendbs -url https://<servername> -sourcedatabasename WSS_Content_1 -destinationdatabasename WSS_Content_2 -operation 3 -filename sites.xml

Painful, right?

If you find yourself using stsadmin on a regular basis... add the stsadmin path into your path variable.  Duh, right?

1.Right-click My Computer, and then click Properties.

2.Click the Advanced tab.

3.Click Environment variables.

image

4.Find the PATH variable, and then click Edit to change its name or value.

image

add a semicolon (;) to the line, and without a space, add the path to the directory that holds stsadm.exe.  The default is c:\Program Files\common files\microsoft shared\web server extensions\12\bin

Hit "OK" a few times, and you can now fire up a terminal and run stsadm without the preceding long path to its home directory.

image