Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@aflyen 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
You can’t perform that action at this time.