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);

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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