Quantcast
Channel: list – farhanfaiz's Weblog – SharePoint 2003/07/10/13/16/19 & Online
Viewing all articles
Browse latest Browse all 9

SharePoint 2010: PowerShell Script to add / display list as webpart

$
0
0

Scenario:

We were required to add / display discussion forum / discussion board as a webpart on a publishing page.

Resolution:

We used “XsltListViewWebPart” webpart to accomplish above requirement

$webpart New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart

$webpart.ListId $list.ID;

$webpart.ViewGuid $list.DefaultView.ID.ToString();

$webpart.AllowClose $false;

$webpart.AllowConnect $false;

$webpart.AllowEdit $false;

$webpart.AllowHide $false;

$webpart.AllowMinimize $false;

$webpart.AllowZoneChange $false;

$webpart.ChromeType = [System.Web.UI.WebControls.WebParts.PartChromeType]::None;

$webpartmanager=$web.GetLimitedWebPartManager($pageUrl,

[System.Web.UI.WebControls.WebParts.PersonalizationScope]

::Shared)

$webpartmanager.AddWebPart($webpart, “Zone 1″, 0);

You need to set following variables:

$list = Get the reference of list. In our case, it was discussion forum

$pageUrl = Url of the page



Viewing all articles
Browse latest Browse all 9

Trending Articles