1 / 18

Web Parts!

Web Parts!. SharePoint + PowerShell User Group August 17, 2012. Agenda. Hello! Group Logistics ( Lync / website / register / email / twitter) Web Parts! Useful Scripts Next meeting. Hello!. Raymond Mitchell SharePoint Consultant http://www.Rackspace.com Author Dad

chione
Download Presentation

Web Parts!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Parts! SharePoint + PowerShell User Group August 17, 2012

  2. Agenda Hello! Group Logistics (Lync / website / register / email / twitter) Web Parts! Useful Scripts Next meeting

  3. Hello! Raymond Mitchell • SharePoint Consultant • http://www.Rackspace.com • Author • Dad • Information Worker Kid • http://www.iwkid.com • SharePoSHing since 2008

  4. What about you?

  5. 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. Show all web parts in the gallery • Open Web Part Gallery in browser, show populate option • Reflector: Microsoft.SharePoint.ApplicationPages.NewDwp • $web = Get-SPWeb http://localhost$safe = [Microsoft.SharePoint.ApplicationRuntime.SharePointHandler]::GetSafeControls($web)$safe | % { $_.FullName; }

  7. SPLimitedWebPartManager SPWeb.GetLimitedWebPartManager Scope – Shared or User FT Title, WebBrowsableObject

  8. Common Web Part Classes Microsoft.SharePoint.WebPartPages.XsltListViewWebPart Microsoft.SharePoint.WebPartPages.ContentEditorWebPart Microsoft.SharePoint.WebPartPages.ImageWebPart Microsoft.SharePoint.WebPartPages.SimpleFormWebPart Microsoft.SharePoint.Publishing.WebControls.MediaWebPart Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart

  9. New Web Part Page $web = Get-SPWeb http://localhost $pages = $web.Lists["Site Pages"] $new = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewWikiPage($pages, "SitePages/SharePoSH.aspx")

  10. 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. New Form Part $web = Get-SPWeb http://localhost $mgr = $web.GetLimitedWebPartManager("/SitePages/SharePoSH.aspx", "Shared") $fwp = New-Object Microsoft.SharePoint.WebPartPages.SimpleFormWebPart $fwp.Content = "<b>Just testing a form</b>"

  12. 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 = "<b>Test!</b>" $cewp.Content = $xmlContent $mgr.AddWebPart($cewp, 0, 0)

  13. 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. 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. Web Services 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. YOUR scripts!

  17. Next Meeting • Friday, September 14th • Topics: • Lists & views • Publishing • IIS / web.config

  18. Resources • PowerShell + SharePoint forum at PowerShell.org: • http://powershell.org/discuss/viewforum.php?f=12

More Related