Saturday, July 2, 2011

Creating Managed Paths Using SQL and STSADM

I recently had to stand up a WSS 2.0 development environment for for a client. They had multiple web apps with over a thousand site collections - each with a managed path. Creating a thousand managed paths in Central Administration manually would not only be time consuming, but if a manually typed in managed path contained a typo, the content would not render in SharePoint when the content database was attached.


To resolve this problem I used the following process to create over a thousand managed paths in a few minutes using SQL and STSADM.

• Execute the following query against the content database:

Select 'stsadm -o addpath -url ' + FullUrl + ' -type explicitinclusion' from Sites Order By FullUrl

• This results in a list of stsadm commands that will create the desired managed paths as shown below:

 
The next step is to copy the resulting text into a batch file. Give the batch file a descriptive name and place it into the directory alongside the STSADM.EXE file.




The final step is to simply open a command prompt and execute the batch file. Once the operations complete, open Central Administration and your managed paths will be installed.




This was a quick, easy way to automate what would have been a tedious task.

No comments:

Post a Comment