How do I know if a page is in modern UI mode using PnPPowerShell ?

Iron Contributor

I need to audit a site and one of my tasks is to ensure that all pages are in Modern UI mode, the other thing I need to know is what Client Side Web Parts are deployed to each page.

 

I want to use the PnP PowerShell commands (or even just PowerShell CSOM commands)

 

Thanks

 

Nigel

 

 

12 Replies

Have you tried using Get-PnPClientSidePage?

Hi Pieter

What is the diffeence between get-PnPWebPart and Get-PnPClientSidePAge ?

I get "object reference not set to an instant of an object" when I use Get-PnPClientSidePage.

I get nothing when I use Get-PnPWebPart

 

 

The page was created in the root site and is has the modern UI.

 

Regards

 

Nigel 

You should get something like this:

 

Get-PnPClientSidePage home.aspx


PageTitle           : 
Sections            : {OfficeDevPnP.Core.Pages.CanvasSection}
Controls            : {7f718435-ee4d-431c-bdbf-9c4ff326f46e, a5df8fdf-b508-4b66-98a6-d83bc2597f63, df611e7c-5498-4843-a936-14e8ec332dcd, eb95c819-ab8f-4689-bd03-0c2d65d47b1f}
LayoutType          : Home
KeepDefaultWebParts : False
Context             : OfficeDevPnP.Core.PnPClientContext
PagesLibrary        : SitePages
PageListItem        : Microsoft.SharePoint.Client.ListItem
DefaultSection      : OfficeDevPnP.Core.Pages.CanvasSection
CommentsDisabled    : False

 if you had a traditional page you would get:

 

Get-PnPClientSidePage : Page 'home.aspx' does not exist

 

 

I have tried this and I get the errors in the attached file.

 

Hi @Nigel Price,

 

You don't need to add the double quotes to the file names. So either:

 

Get-PnPClientSidePage A-Modern-Page.aspx 

or

if you prefer to enter it on the Identity prompt then also no quotes.

Ah I wonder mayb e the - in the file name?

 

Can you try it with the default home.aspx file?

Hi Pieter 

 

I tried that and I still get the "Object Reference not set to an instance of an Object"

 

Regards

 

Nigel

Can you add to your scripts the $web like below:

 

$web = Get-PnPWeb
Write-Host $web.Url
Get-PnPClientPageSidePage -Web $web -Identity home.aspx

Just another thought, you could try Get-PnPProvisioingTemplate -Out temp.xml

 

Then you should find the page in there and check if you can find the modern web parts there.

 

Hi Pieter

 

I thought a provisioning template only had the home page in it ?

 

Regards

 

Nigel

Could you set it to the default page for testing purposes.
Ah, that reminds me, I had something like this when I tried to export a list view page in the past.

@Nigel Price 

Get-PnPClientSidePage throws error if you are trying to find details of OOTB pages (or pages created in browser). 

It works on custom pages created using pnp cmdlets.

Here is the issue opened in Github. 

https://github.com/SharePoint/PnP-PowerShell/issues/1947