Add-PnPWebPartToWebPartPage

Tip

We encourage you to make improvements to this documentation. Please navigate to https://github.com/pnp/powershell/blob/dev/documentation/Add-PnPWebPartToWebPartPage.md to change this file.

Adds a web part to a web part page in a specified zone

Syntax

Add-PnPWebPartToWebPartPage
   -ServerRelativePageUrl <String>
   -Xml <String>
   -ZoneId <String>
   -ZoneIndex <Int32>
   [-Connection <PnPConnection>]
   [<CommonParameters>]
Add-PnPWebPartToWebPartPage
   -ServerRelativePageUrl <String>
   -Path <String>
   -ZoneId <String>
   -ZoneIndex <Int32>
   [-Connection <PnPConnection>]
   [<CommonParameters>]

Examples

EXAMPLE 1

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/demo/sitepages/home.aspx" -Path "c:\myfiles\listview.webpart" -ZoneId "Header" -ZoneIndex 1

This will add the web part as defined by the XML in the listview.webpart file to the specified page in the specified zone and with the order index of 1

EXAMPLE 2

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/sites/demo/sitepages/home.aspx" -XML $webpart -ZoneId "Header" -ZoneIndex 1

This will add the web part as defined by the XML in the $webpart variable to the specified page in the specified zone and with the order index of 1

Parameters

-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:PnPConnection
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Path

A path to a web part file on a the file system.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ServerRelativePageUrl

Server Relative Url of the page to add the web part to.

Type:String
Aliases:PageUrl
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Xml

A string containing the XML for the web part.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ZoneId

The Zone Id where the web part must be placed

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ZoneIndex

The Zone Index where the web part must be placed

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False