Comparing Administrative Options for SharePoint 2010

The following exercise was undertaken in preparation for my upcoming session at the Federal SharePoint Technical User Group session on PowerShell. I wanted to prove to my audience just how fast and better PowerShell was compared to all the other Administrative options for SharePoint. I decided to go ahead and do a fairly quick and sample test, and calculate benchmarks out of it for each option.

 

The tests consisted in creating 5 site collections (each under a distinct Web Application), and have 15 new Webs created under each of them, for a total of 75 webs, and 5 site collections. The following blog article describes the benchmarks for each of the following options:

  1. STSAdm
  2. Object Model
  3. PowerShell
  4. Web Services

 

STSAdm

Alright, so we all know STSAdm. It’s been around for ages, since the original SharePoint Team Sites product in the early 2000. I went ahead and created the following batch file that implicitly called the STSAdm executable for every command:

prompt $p$g $t –

cd “C:\Program Files\Common Files\Microsoft Shared\Web server Extensions\14\BIN\”

 

stsadm -o createsite -url “http://spdemo:82/sites/SiteColl1” -ownerlogin “litware\Nik.Charlebois” -owneremail “Nik.Charlebois@Litware.com”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web1”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web2”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web3”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web4”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web5”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web6”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web7”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web8”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web9”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web10”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web11”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web12”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web13”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web14”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl1/Web15”

 

stsadm -o createsite -url “http://spdemo:82/sites/SiteColl2” -ownerlogin “litware\Nik.Charlebois” -owneremail “Nik.Charlebois@Litware.com”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web1”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web2”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web3”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web4”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web5”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web6”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web7”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web8”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web9”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web10”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web11”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web12”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web13”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web14”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl2/Web15”

 

stsadm -o createsite -url “http://spdemo:82/sites/SiteColl3” -ownerlogin “litware\Nik.Charlebois” -owneremail “Nik.Charlebois@Litware.com”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web1”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web2”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web3”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web4”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web5”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web6”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web7”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web8”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web9”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web10”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web11”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web12”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web13”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web14”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl3/Web15”

 

stsadm -o createsite -url “http://spdemo:82/sites/SiteColl4” -ownerlogin “litware\Nik.Charlebois” -owneremail “Nik.Charlebois@Litware.com”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web1”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web2”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web3”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web4”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web5”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web6”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web7”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web8”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web9”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web10”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web11”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web12”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web13”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web14”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl4/Web15”

 

stsadm -o createsite -url “http://spdemo:82/sites/SiteColl5” -ownerlogin “litware\Nik.Charlebois” -owneremail “Nik.Charlebois@Litware.com”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web1”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web2”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web3”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web4”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web5”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web6”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web7”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web8”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web9”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web10”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web11”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web12”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web13”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web14”

stsadm -o createweb -url “http://spdemo:82/sites/SiteColl5/Web15”

 

Running this script took a total of 14 minutes and 36 seconds (14:26).

Object Model

The Object Model on the other hand, allows one to write recursive loops in a more friendly way than writing them in command line script would have been. I created a new console application in C#, added a reference to the Microsoft.SharePoint v14 assembly, and made elevated calls to the proper methods. Here’s the code for the method I used:

static void Main(string[] args)

{

SPSecurity.RunWithElevatedPrivileges(delegate(){

 

DateTime time = DateTime.Now;

SPWebApplication webAPP = SPWebApplication.Lookup(new Uri(“http://spdemo:83”));

for (int i = 1; i <= 5; i++)

{

try

{

using (SPSite site = webAPP.Sites.Add(“http://spdemo:83/sites/SiteColl” + i.ToString(), @”Litware\Nik.Charlebois”, “nik.Charlebois@Litware.com”))

{

Console.Out.WriteLine(“Site Collection #” + i.ToString() + ” Created”);

for (int j = 1; j <= 15; j++)

{

using (SPWeb web = site.AllWebs.Add(“Web” + j.ToString()))

{

Console.Out.WriteLine(“\tWeb #” + j.ToString() + ” Created”);

}

}

}

}

catch { }

}

Console.Out.WriteLine(“\r\nIt took ” + (DateTime.Now.Subtract(time).TotalSeconds).ToString() + ” seconds to execute”);

});

}

 

Executing the operation using the Object Model took a total of 1,063 seconds so 17 minutes total.

PowerShell

The third option, which really was the focus of my little exercise, is PowerShell. IT people have been able to use PowerShell to manage SharePoint since the 2007 version, and even if I’ve never played with it, it could be done for SharePoint 2003. PowerShell is such an amazing tool. I find it finally gets rid of that Gap between developers and IT Pros. Administrators now have to start learning the artifacts of the SharePoint ecosystem, and finally get to start speaking the same language as developers (SPWebs, SPSite, etc). Here’s my PowerShell code for executing the operations. Please note that if you start it directly from the SharePoint PowerShell Management Shell, you do no need to include the first line to add the SharePoint Snapin.

Add-PSSnapin Microsoft.SharePoint.PowerShell

$time = Get-Date

$spWebApp = Get-SPWebApplication http://spdemo:81;

 

for($i = 1; $i -le 5; $i++)

{

$url =” http://spdemo:81/sites/SiteColl$i”;

new-spsite $url -OwnerAlias “Litware\Administrator” -OwnerEmail “Administrator@Litware.com”;

Write-Host “Site Collection #$i Created”;

for($j = 1; $j -le 15; $j++)

{

$url = ” http://spdemo:81/sites/SiteColl$i/Web$j”;

 

new-spweb $url;

Write-Host “Web #$j Created”;

}

}

$now = Get-Date

$benchmark = $now.Subtract($time)

Write-Host $benchmark.TotalSeconds;

 

Just look at how simple the code is, and just how close to the Object Model code it looks. I wasn’t surprised to see that PowerShell was the fastest of all tests, scoring a 296 seconds or 5 minutes to execute.

Web Services

Just to be fair, I had to go and evaluate all possible options, including this last one, the Web Service API. SharePoint out of the box comes with a wide range of different Web Services of all kinds of flavor. To execute this test, I had to make calls to 2 distinct web services. The first one, being the Central Admin service, which allows us to create new Site collections. By default, this web service is located at http://<servername>/_vti_adm/admin.asmx. The second web service, is the one that would allow me to create Webs under the newly created Site Collection. This one is located at http://<servername>/_vti_bin/sites.asmx. To test this API, I went ahead and created a new Console App in C#, and called the following method:

static void Main(string[] args)

{

DateTime begin = DateTime.Now;

CentralAdmin.Admin proxy = new CentralAdmin.Admin();

SitesWS.Sites sitesWS = new SitesWS.Sites();

sitesWS.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

 

for (int i = 1; i <= 5; i++)

{

proxy.CreateSite(“http://spdemo:84/sites/SiteColl” + i.ToString(), “SiteColl” + i.ToString(), “”, 1033, “STS#1”, “Litware\\Administrator”, “Nik”, “Administrator@Litware.com”,””,””);

Console.WriteLine(“Site Collection #” + i.ToString() + ” Created…”);

for (int j = 1; j <= 15; j++)

{

sitesWS.Url = “http://spdemo:84/sites/SiteColl” + i.ToString() + “/_vti_bin/sites.asmx”;

try

{

sitesWS.CreateWeb(“Web” + j.ToString(), “Web #” + j.ToString(), “”, “STS”, 1033, true, 1033, true, 1033, true, true, true, true, true, true, true);

}

catch { }

Console.Out.WriteLine(“\tWeb #” + j.ToString() + ” Created…”);

}

}

Console.WriteLine(“Completed in ” + DateTime.Now.Subtract(begin).TotalSeconds);

}

 

In theory, I was expecting this test to be the slowest one of them all. I was very surprised to see that it scored a respectable 13 minutes and 30 seconds. Therefore beating both STSAdm and the Object Model has the fastest method of creating batch sites. Please note, however that this was executed on the SharePoint server itself, so there was no delay sending the Soap Envelops over the wire.

 

Summary

Here’s a table to summarize my findings. PowerShell, as expected is the undisputed King of Management tools for SharePoint!

Method Name Time of Execution (in minutes)
STSAdm 15
Object Model 17
PowerShell 5
Web Services 13.5

Microsoft Premier Field Engineer - SharePoint

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*