SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add a new developed WebPart to a SharePoint site with PowerShell.

How it is possible to add the WebPart reference from my WebPart to the PowerShell script?

$web = Get-SPWeb $urlWeb

$webpartmanager=$web.GetLimitedWebPartManager($urlWebWP,  [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$webpart = new-object  ReferenceToMyWebPartProblem

$webpartmanager.AddWebPart($webpart, $webpartzone, $index);
share|improve this question
up vote 2 down vote accepted

Here is a link to a page that describes the process for the out of the box SharePoint webparts. If you want to include your own webpart, you need to add a reference to your assembly in powershell. The following line adds a reference to one of my custom webparts into powershell.

 [System.Reflection.Assembly]::Load("rossri.NavigationControl, Version=, Culture=neutral, PublicKeyToken=a60d1a662835ad70")

Once the reference is added, I can then create a new object of the type of my custom webpart. For fun I changed the title and then added it using the webpartmanager object.

$webpart = New-Object rossri.NavigationControl.UserListViewPart.UserListViewPart
$webpart.Title = "NewPart from Powershell"
$webpartmanager.AddWebPart($webpart, "Left", "0")

I checked the page and it was added to the zone I defined.

share|improve this answer
Thank you so much! Great comment! – LaPhi Aug 30 '11 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.