Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Issue - Get-PnPSiteDesign Get-PnPSiteScript #2002

Open
2 of 6 tasks
ypcode opened this issue Apr 3, 2019 · 2 comments
Open
2 of 6 tasks

Issue - Get-PnPSiteDesign Get-PnPSiteScript #2002

ypcode opened this issue Apr 3, 2019 · 2 comments

Comments

@ypcode
Copy link
Contributor

ypcode commented Apr 3, 2019

Reporting an Issue or Missing Feature

I get an issue when I try either Get-PnPSiteDesign or Get-PnPSiteScript in order the get the list of designs (or scripts)
I tried as well specifying the Id of script or design but get the same NullReferenceException

Expected behavior

Get the list of site designs and site scripts in my tenant

Actual behavior

image

image

Steps to reproduce behavior

Connect-PnPOnline https://tenant.sharepoint.com -UseWebLogin
Get-PnPSiteDesign
# ERROR
Get-PnPSiteScript
# ERROR
Get-PnPSiteScript -Identity <id_of_my_script>
# ERROR

Which version of the PnP-PowerShell Cmdlets are you using?

  • PnP PowerShell for SharePoint 2013
  • PnP PowerShell for SharePoint 2016
  • PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

The latest march 2019 release
ModuleType Version Name ExportedCommands


Binary 3.7.1903.0 SharePointPnPPowerShellOnline

How did you install the PnP-PowerShell Cmdlets?

  • MSI Installed downloaded from GitHub
  • Installed through the PowerShell Gallery with Install-Module
  • Other means
@ypcode
Copy link
Contributor Author

ypcode commented Apr 5, 2019

FYI, I just noticed that only happens when I connect using WebLogin (with my admin account),
with direct credentials, it works just fine

@sionjlewis
Copy link

sionjlewis commented Apr 15, 2020

I can confirm that I'm seeing the same error when using UserWebLogin

Connect-PnPOnline -Url "https://<TENANT>.sharepoint.com/<PATH>/<SITE>" -UseWebLogin;
Get-PnPConnection;

The error message returned is:

Get-PnPSiteDesign : The remote server returned an error: (403) Forbidden.
At line:1 char:1

  • Get-PnPSiteDesign
  •   + CategoryInfo          : NotSpecified: (:) [Get-PnPSiteDesign], WebException
      + FullyQualifiedErrorId : System.Net.WebException,SharePointPnP.PowerShell.Commands.GetSiteDesign
    

But it works fine when using Credentials

Connect-PnPOnline -Url "https://<TENANT>.sharepoint.com/<PATH>/<SITE>" -Credentials (Get-Credential);
Get-PnPConnection;

Is there any progress in a fix?

UPDATE #1 - WORK AROUND

To get the Get-PnPConnection to work with UserWebLogin you need to connect to your SharePoint Admin site like so:

Connect-PnPOnline -Url "https://<TENANT>-admin.sharepoint.com" -UseWebLogin;
Get-PnPConnection;

This does mean that PnP example below is not good, as you would applying the site design to the SharePoint Admin Center...

Get-PnPSiteDesign | ?{$_.Title -eq "Demo"} | Invoke-PnPSiteDesign

Instead you could do something like this:

Connect-PnPOnline -Url "https://<TENANT>-admin.sharepoint.com" -UseWebLogin;
$siteDesign = Get-PnPSiteDesign | ?{$_.Title -eq $row.SiteDesignName};
Invoke-PnPSiteDesign -Identity $siteDesign.Id -WebUrl "https://<TENANT>.sharepoint.com/<PATH>/<SITE>";

Noting forgetting to disconnect of cause :)

Disconnect-PnPOnline;

Update #2

Apparently Add-PnPSiteDesignTask has superseded the above CmdLet, see Microsoft's documentation for more info:
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpsitedesigntask?view=sharepoint-ps

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants