Skip to content

Instantly share code, notes, and snippets.

@aflyen
Last active October 28, 2015 11:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aflyen/5db65f5ab6da792c3ced to your computer and use it in GitHub Desktop.
Enable export on web parts in SharePoint (on-premises)
# Configuration
$WebUrl = "http://intranet.contoso.com"
$PageUrl = "/Pages/default.aspx"
$WebPartName = "Documents"
# Enables export mode
$Web = Get-SPWeb $WebUrl
$File = $Web.GetFile($Web.ServerRelativeUrl + $PageUrl)
$File.CheckOut()
$Wpm = $File.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$WebParts = $Wpm.WebParts
$WebPart = $WebParts | where { $_.Title -eq $WebPartName }
$WebPart.ExportMode = [System.Web.UI.WebControls.WebParts.WebPartExportMode]::All
$Wpm.SaveChanges($WebPart)
$File.CheckIn("", [Microsoft.SharePoint.SPCheckInType]::MajorCheckIn)
@aflyen
Copy link
Author

aflyen commented Oct 28, 2015

This is primarily used for enabling export of the XsltListViewWebPart. The XsltListViewWebPart doesn't allow export by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment