SharePoint 2016/PnP powershell: how to get page content?

%3CLINGO-SUB%20id%3D%22lingo-sub-277826%22%20slang%3D%22en-US%22%3ESharePoint%202016%2FPnP%20powershell%3A%20how%20to%20get%20page%20content%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-277826%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20using%20SharePoint%202016.%20I%20am%20working%20alot%20with%20PnP%20powershell.%20I%20would%20like%20to%20use%20the%20command%20%22Get-PnPProvisioningTemplate%22%20to%20get%20the%20content%20of%20the%20welcomepage%20which%20is%20an%20publishing%20page.%20But%20in%20the%20xml%20template%20I%20dont%20see%20the%20page%20content.%20I%20have%20read%20there%20are%20some%20issues%20when%20you%20try%20this%20and%20you%20use%20in%20the%20connect%20the%20parameter%20-UseLogin.%20Because%20we%20are%20using%20SharePoint%202016%20in%20combination%20with%20ADFS%20and%20MFA%20(Multi%20factor%20authentication)%20we%20need%20to%20use%20the%20parameter%20-UseLogin.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20another%20way%20to%20get%20the%20welcomepage%20content%20in%20xml%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20use%20at%20this%20moment%20this%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-PnPOnline%20-Url%20%22%3CA%20href%3D%22https%3A%2F%2Fmycompany.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmycompany.com%3C%2FA%3E%22%20-UseWebLogin%3C%2FP%3E%3CP%3EGet-PnPProvisioningTemplate%20-Out%20%22c%3A%5Cmytemplate.xml%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20xml%20template%20I%20see%20alot%20like%3A%20propertybag%2C%20security%2C%20columns%2C%20contenttypes%2C%20lists.%20But%20no%20Pages%20section.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-277826%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-278878%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%202016%2FPnP%20powershell%3A%20how%20to%20get%20page%20content%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-278878%22%20slang%3D%22en-US%22%3E%3CP%3EI%20will%20try%20it%20and%20let%20you%20know%20if%20it%20works.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-277847%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%202016%2FPnP%20powershell%3A%20how%20to%20get%20page%20content%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-277847%22%20slang%3D%22en-US%22%3E%3CP%3EHave%20you%20tried%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fget-pnpclientsidepage%3Fview%3Dsharepoint-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGet-PnPClientSidePage%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fget-pnpwikipagecontent%3Fview%3Dsharepoint-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGet-PnPWikiPageContent%3C%2FA%3E%26nbsp%3B%3F%3C%2FP%3E%3CP%3EOne%20of%20them%20should%20do%20the%20trick%2C%20but%20if%20not%2C%20you%20can%20extract%20the%20XML%20of%20each%20web%20part%20on%20the%20page%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fsharepoint-pnp%2Fget-pnpwebpartxml%3Fview%3Dsharepoint-ps%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGet-PnPWebPartXML%3C%2FA%3E%20and%20manually%20build%20the%20page%20XML%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehope%20this%20helps%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

We are using SharePoint 2016. I am working alot with PnP powershell. I would like to use the command "Get-PnPProvisioningTemplate" to get the content of the welcomepage which is an publishing page. But in the xml template I dont see the page content. I have read there are some issues when you try this and you use in the connect the parameter -UseLogin. Because we are using SharePoint 2016 in combination with ADFS and MFA (Multi factor authentication) we need to use the parameter -UseLogin.

 

Is there another way to get the welcomepage content in xml?

 

I use at this moment this command:

 

Connect-PnPOnline -Url "https://mycompany.com" -UseWebLogin

Get-PnPProvisioningTemplate -Out "c:\mytemplate.xml"

 

In the xml template I see alot like: propertybag, security, columns, contenttypes, lists. But no Pages section.

2 Replies
Highlighted

Have you tried Get-PnPClientSidePage or Get-PnPWikiPageContent ?

One of them should do the trick, but if not, you can extract the XML of each web part on the page using Get-PnPWebPartXML and manually build the page XML

 

hope this helps

 

Highlighted

I will try it and let you know if it works.