Archive for January, 2011

SharePoint 2010: PowerShell Script – Create custom List


We need to create PowerShell script to create custom list in a web




$weburl = Read-Host “Please enter web url (like :”

$spweb = Get-SPWeb $weburl


$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::GenericList

$spweb.Lists.Add(“My List”,”My list description”,$listTemplate)

write-host “List added in the Web : ” $spweb -foregroundcolor Yellow



catch [System.SystemException]


write-host “Execution stopped due to: “+$_.Message -foregroundcolor Red



Leave a Comment

SPWebPartManager.SaveChanges – Parameters

We need to update or change properties of a web part on different pages. For this, wrote a power shell script that updates or change the properties of the webpart. When we try to save the change properties using SPWebPartManager.SaveChanges method, our script through exception

As per MS, SPWebPartManager.SaveChanges takes storageKey as valid parameter but our script through exception every time we run it with the storageKey as parameter.

Google it and tried to pass webpart as parameter. Worked like a charm.

Still looking at the documentation and wondering………………….

Leave a Comment