pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Add-PnPClientSideWebPart is not working #2605

Open tsvaishnav opened 4 years ago

tsvaishnav commented 4 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

Reporting an Issue

Expected behavior

I expect that a new webpart will be added to home page when I run the following code 👍

Add-PnPClientSideWebPart -Page "Home" -Component d5196c4d-3be7-462f-9909-061d73b94631 -Section 1 -Column 2 -Order 1

Actual behavior

I get this error :

Add-PnPClientSideWebPart : Cannot bind parameter 'DefaultWebPartType'. Cannot convert value "NewDocLib" to type "OfficeDevPnP.Core.Pages.DefaultClientSideWebParts". Error: "Unable to match the identifier name NewDocLib to a valid
enumerator name. Specify one of the following enumerator names and try again:
ThirdParty, ContentRollup, BingMap, ContentEmbed, DocumentEmbed, Image, ImageGallery, LinkPreview, NewsFeed, NewsReel, News, PowerBIReportEmbed, QuickChart, SiteActivity, VideoEmbed, YammerEmbed, Events, GroupCalendar, Hero, List,
PageTitle, People, QuickLinks, CustomMessageRegion, Divider, MicrosoftForms, Spacer, ClientWebPart, PowerApps, CodeSnippet, PageFields, Weather, YouTube, MyDocuments, YammerFullFeed, CountDown, ListProperties, MarkDown, Planner, Sites,
CallToAction, Button"
At line:1 char:59
+ ... PClientSideWebPart -Page "Home" -DefaultWebPartType NewDocLib -Sectio ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Add-PnPClientSideWebPart], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,SharePointPnP.PowerShell.Commands.WebParts.AddClientSideWebPart

Please note that this happens only for non-default webparts. For instance, webparts like news and activity, the code runs fine.

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists

Step 1: Create a new document library on Sharepoint online called "NewDocLib" Ste p 2 : Run the following code:

PS C:\WINDOWS\system32>> Set-Variable -Name "NewDocLib" -Value ((Get-PnPList -Identity "NewDocLib").Id)
PS C:\WINDOWS\system32>> Add-PnPClientSideWebPart -Page "Home" -Component $NewDocLib -Section 1 -Column 2 -Order 1

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

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

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)

SharePointPnPPowerShellOnline

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.