Home >

PowerShell and SharePoint 2010

3. March 2011

If you are a SharePoint developer or administrator, then start learning Power Shell. It’s a must have skill for dealing with SharePoint from now on wards.

Windows Power Shell is an interactive command line and task based scripting technology which allows administrators to automate administrative tasks.

From SharePoint viewpoint, Power Shell has significant performance benefits:

image image

Here is the Power Shell script to enable a feature on every SPSite:

$rawdata = stsadm.exe -o enumsites -url $WebAppURL   
$sitexml = [XML]$rawdata
$sitesxml.Sites | foreach-object{ $_.Site } | foreach-object{
  stsadm -o activatefeature -url $_.url -filename $featureFileName
         if( $lastexitcode -ne 0 ){ 
            Write-Host “Failure:$lastexitcode `n" -Fore Red;
            $failure = $true; 
         }
}
 

It will take 12+ hours for 5300 SharePoint sites. Whereas same code in Power Shell would be like following:

Get-SPSite –Limit ALL –WebApplication $WebAppNameorUrl |%{ 
   Enable-SPFeature $FeatureIdOrName –url $_.Url 
}

And this will take only 30 minutes for same 5300 sites :-)

So learn Power Shell and start rolling with all new 652 power shell cmdlets in SharePoint 2010 as compared to STSADM based 182 commands in SharePoint 2007.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading