Quantcast
Channel: SharePoint 2010 - General Discussions and Questions forum
Viewing all articles
Browse latest Browse all 17574

Powershell script to add/modify listviewwebpart summary view

$
0
0

Hi,

My requirement is to add a listviewwebpart to sevarala publishing pages and i am trying to do it through powershell.

I need only 'summary view' to be added as default when this web part is added. My example script is:

$SPWeb = Get-SPWeb $WebUrl
$wpPage = $SPWeb.GetFile("Pages\Default.aspx")


$wpPage.Checkout()

$wpManager = $wpPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$list = $SPWeb.Lists["Calendar"]
$wpView = New-Object "Microsoft.SharePoint.WebPartPages.ListViewWebPart"
 $wpView.ListName = $list.ID.ToString("B").ToUpper()

 $wpView.ViewType = "None" 

$wpView.ViewGuid = ""

$wpManager.AddWebPart($wpView,"RightZone",2)
$wpManager.SaveChanges($wpView)

But this code is adding default calendar view to the page but i need only summary view to be added to the page. how can id do that?

TIA.


Viewing all articles
Browse latest Browse all 17574


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>