I am try to programatically add a library webpart to page. I've tried the below code with no luck

%3CLINGO-SUB%20id%3D%22lingo-sub-1214464%22%20slang%3D%22en-US%22%3EI%20am%20try%20to%20programatically%20add%20a%20library%20webpart%20to%20page.%20I've%20tried%20the%20below%20code%20with%20no%20luck%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1214464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%3EAdd-PnPClientSideWebPart%20-Page%20%24page%20-DefaultWebPartType%20Library%20-WebPartProperties%20%40%7B%22selectedListID%22%20%3D%20%220feb0257-f487-4c19-a8b0-9cf40f240222%22%7D%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3EAny%20help%20would%20be%20appreciated.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%3EPweetster%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1218444%22%20slang%3D%22en-US%22%3ERe%3A%20I%20am%20try%20to%20programatically%20add%20a%20library%20webpart%20to%20page.%20I've%20tried%20the%20below%20code%20with%20no%20luc%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1218444%22%20slang%3D%22en-US%22%3E-DefaultWebPartType%20List.%20It%20works%20for%20libraries%20too.%20You%20can%20add%20%22isDocumentLibrary%22%3Atrue%20to%20the%20WebPartProperties%20parameter%2C%20but%20I%20don't%20think%20it's%20necessary.%3C%2FLINGO-BODY%3E
Occasional Visitor

Add-PnPClientSideWebPart -Page $page -DefaultWebPartType Library -WebPartProperties @{"selectedListID" = "0feb0257-f487-4c19-a8b0-9cf40f240222"}

 

Any help would be appreciated.

Pweetster

1 Reply
-DefaultWebPartType List. It works for libraries too. You can add "isDocumentLibrary":true to the WebPartProperties parameter, but I don't think it's necessary.