Presentation is loading. Please wait.

Presentation is loading. Please wait.

PS SharePoSH:\> Web Parts! SharePoint + PowerShell User Group August 17, 2012.

Similar presentations


Presentation on theme: "PS SharePoSH:\> Web Parts! SharePoint + PowerShell User Group August 17, 2012."— Presentation transcript:

1 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Web Parts! SharePoint + PowerShell User Group August 17, 2012

2 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Agenda Hello! Group Logistics (Lync / website / register / email / twitter) Web Parts! Useful Scripts Next meeting

3 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Raymond Mitchell SharePoint Consultant – http://www.Rackspace.com http://www.Rackspace.com Author Dad Information Worker Kid – http://www.iwkid.com http://www.iwkid.com SharePoSHing since 2008 Hello!

4 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH What about you?

5 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Web Parts + PowerShell Web Part Basics Review Show all web parts in the gallery SPLimitedWebPartManager Different Web Part Classes Adding a Web Part Editing/Saving properties of a Web Part Searching for Web Parts (closed/by type) Export Web Parts Web Part Page Web Service

6 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Show all web parts in the gallery Open Web Part Gallery in browser, show populate option Reflector: Microsoft.SharePoint.ApplicationPages.NewD wp $web = Get-SPWeb http://localhost $safe = [Microsoft.SharePoint.ApplicationRuntime.SharePointHandler]::GetSafeControls($web) $safe | % { $_.FullName; }

7 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH SPLimitedWebPartManager SPWeb.GetLimitedWebPartManager Scope – Shared or User FT Title, WebBrowsableObject

8 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Common Web Part Classes Microsoft.SharePoint.WebPartPages.XsltListViewWebPart Microsoft.SharePoint.WebPartPages.ContentEditorWebPart Microsoft.SharePoint.WebPartPages.ImageWebPart Microsoft.SharePoint.WebPartPages.SimpleFormWebPart Microsoft.SharePoint.Publishing.WebControls.MediaWebPa rt Microsoft.SharePoint.Publishing.WebControls.ContentByQu eryWebPart

9 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH New Web Part Page $web = Get-SPWeb http://localhost $pages = $web.Lists["Site Pages"] $new = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewWikiPage($p ages, "SitePages/SharePoSH.aspx")

10 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH New XSLT List View Web Part $web = Get-SPWeb http://localhost $pages = $web.Lists["Site Pages"] $wp = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart $wp.ListId = $pages.ID $wp.ViewGuid = $pages.DefaultView.ID $mgr = $web.GetLimitedWebPartManager("/SitePages/SharePoSH.aspx", "Shared") $mgr.AddWebPart($wp, 0, 0)

11 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH New Form Part $web = Get-SPWeb http://localhost $mgr = $web.GetLimitedWebPartManager("/SitePages/SharePoSH.aspx", "Shared") $fwp = New-Object Microsoft.SharePoint.WebPartPages.SimpleFormWebPart $fwp.Content = " Just testing a form "

12 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH New CEWP $web = Get-SPWeb http://localhost $mgr = $web.GetLimitedWebPartManager("/SitePages/SharePoSH.aspx", "Shared") $cewp = New-Object Microsoft.SharePoint.WebPartPages.ContentEditorWebPart $xml = New-Object -TypeName xml $xmlContent = $xml.CreateElement("Content") $xmlContent.InnerText = " Test! " $cewp.Content = $xmlContent $mgr.AddWebPart($cewp, 0, 0)

13 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Find Web Parts $web = Get-SPWeb http://localhost $mgr = $web.GetLimitedWebPartManager("/SitePages/SharePoSH.aspx", "Shared") $mgr.WebParts | ? { $_.IsClosed -eq $true } | ft title, WebBrowsableObject $mgr.WebParts | ? { $_.WebBrowsableObject.ToString().Contains("Form") } | ft title, WebBrowsableObject

14 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Export Web Part $wp = $mgr.WebParts[0] $sw = New-Object System.IO.StringWriter $xw = [System.xml.XmlWriter]::Create($sw) $mgr.ExportWebPart($wp, $xw) $xw.Close() $sw.Close() $sw.ToString()

15 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Web Services http://msdn.microsoft.com/en- us/library/ms774747(v=office.12) http://msdn.microsoft.com/en- us/library/ms774747(v=office.12) $proxy = New-WebServiceProxy http://localhost/_vti_bin/WebPartPages.asmx $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials $proxy.GetWebPartPage("/SitePages/SharePoSH.aspx", "Version3")

16 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH YOUR scripts!

17 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Next Meeting Friday, September 14 th Topics: – Lists & views – Publishing – IIS / web.config

18 PS SharePoSH:\> http://www.SharePoSH.comhttp://www.SharePoSH.com @SharePoSH@SharePoSH Resources PowerShell + SharePoint forum at PowerShell.org: – http://powershell.org/discuss/viewforum.php?f=1 2 http://powershell.org/discuss/viewforum.php?f=1 2


Download ppt "PS SharePoSH:\> Web Parts! SharePoint + PowerShell User Group August 17, 2012."

Similar presentations


Ads by Google