Forum Discussion
tvaishnav
Apr 07, 2020Copper Contributor
Add-PnPClientSideWebPart not working in Sharepoint online
I am trying to add a new webpart (document library) using Add-PnPClientSideWebPart.
I am using following code :
Set-Variable -Name "NewDocLib" -Value ((Get-PnPList -Identity "NewDocLib").Id)
Add-PnPClientSideWebPart -Page "Home" -Component $NewDocLib -Section 1 -Column 2 -Order 1
This is as per following article :
I am getting following error :
Add-PnPClientSideWebPart : Value cannot be null.
Parameter name: Passed in component cannot be null
At line:1 char:1
+ Add-PnPClientSideWebPart -Page "Home" -Component $NewDocLib -Section ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPClientSideWebPart], ArgumentNullException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.WebParts.AddClientSideWebPart
Can I get some help?
1 Reply
Sort By
- Animesh JoshiBrass Contributorlooking at the error variable $NewDocLib is null
it seems Get-PnPList -Identity "NewDocLib").Id is not returning anything
what do you see if you add write-host "$($NewDocLib)" after line 1 and before line 2