PnP-Powershell to upload files into Document Sets

%3CLINGO-SUB%20id%3D%22lingo-sub-56854%22%20slang%3D%22en-US%22%3EPnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56854%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3EHas%20anyone%20seen%20any%20PnP-PowerShell%20to%20upload%20a)%20a%20file%20in%20Windows%20filestore%20into%20an%20existing%20document%20set%20or%20b)%20upload%20multiple%20files%20in%20Windows%20filestore%20into%20an%20existing%20document%20set%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20file%20PnP-Powershell%20to%20create%20Document%20Sets%2C%20Delete%20Document%20sets%20etc%2C%20but%20not%20add%20files%20to%20an%20existing%20document%20set.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%40VesaJuvenon%20%40ErwinVanHunen%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENigel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-217121%22%20slang%3D%22en-US%22%3ERe%3A%20PnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-217121%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EFirst%20of%20all%2C%20make%20sure%20that%20you%20connected%20to%20the%20correct%20site.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESecondly%2C%26nbsp%3B%20try%20this%20code.%20Path%20is%20a%20positional%20parameter%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAdd-PnPFile%20-Path%20%22C%3A%5Ctemp%5CNormalFileName.txt%22%26nbsp%3B-Folder%20%22Shared%20Documents%2Fdocuments%22%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-73176%22%20slang%3D%22en-US%22%3ERe%3A%20PnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-73176%22%20slang%3D%22en-US%22%3E%3CP%3ENarasimaPerumal%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20your%20suggestion%2C%20with%20my%20substitutions%3A%3C%2FP%3E%3CP%3EAdd-PnPFile%20-Folder%20%22Shared%20Documents%2Fdocuments%22%20-Path%20%22C%3A%5Ctemp%5CNormalFileName.txt%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20get%20the%20error%3A%26nbsp%3B%20Add-PnPFile%20%3A%20Local%20file%20was%20not%20found.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYet%20I%20can%20see%20the%20file%20in%20Windows%20Explorer.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20get%20a%20Powershell%20script%20working%20to%20load%20files%20in%20a%20hard%20drive%2Ffile%20share%20to%20SharePoint%20Online.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-57352%22%20slang%3D%22en-US%22%3ERe%3A%20PnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-57352%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3694%22%20target%3D%22_blank%22%3E%40NarasimaPerumal%20Chandramohan%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%26nbsp%3Bfor%20the%20responses.%26nbsp%3B%20Works%20good.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-56955%22%20slang%3D%22en-US%22%3ERe%3A%20PnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56955%22%20slang%3D%22en-US%22%3E%3CP%3ETry%20in%20the%20below%20format%2C%20specify%20the%20document%20set%20as%20%3CLIBRARY%20name%3D%22%22%3E%2F%3CDOCUMENT%20set%3D%22%22%20name%3D%22%22%3E%3C%2FDOCUMENT%3E%3C%2FLIBRARY%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EAdd-PnPFile%20-Folder%20%22Shared%20Documents%2Fdocsetfolder1%22%20-Path%20%22C%3A%5Ctest1.xml%22%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-56951%22%20slang%3D%22en-US%22%3ERe%3A%20PnP-Powershell%20to%20upload%20files%20into%20Document%20Sets%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56951%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F4102%22%20target%3D%22_blank%22%3E%40Nigel%20Price%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20you%20tried%20adding%20the%20fiels%20in%20the%20same%20way%20as%20you%20would%20do%20with%20a%20folder%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20with%20Add-PnPFile%20something%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%20class%3D%22container%20new-discussion-timeline%20experiment-repo-nav%22%3E%3CDIV%20class%3D%22repository-content%22%3E%3CDIV%20class%3D%22file%22%3E%3CDIV%20class%3D%22readme%20blob%20instapaper_body%22%3E%3CDIV%20class%3D%22highlight%20highlight-source-powershell%22%3E%3CPRE%3EPS%3A%3CSPAN%20class%3D%22pl-k%22%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-c1%22%3EAdd-PnPFile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-k%22%3E-%3C%2FSPAN%3EPath%20.%5Csample.doc%20%3CSPAN%20class%3D%22pl-k%22%3E-%3C%2FSPAN%3EFolder%20%3CSPAN%20class%3D%22pl-s%22%3E%22Shared%20Documents%2FDocumentSetName%22%3C%2FSPAN%3E%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Contributor

Hi

Has anyone seen any PnP-PowerShell to upload a) a file in Windows filestore into an existing document set or b) upload multiple files in Windows filestore into an existing document set ?

 

I can file PnP-Powershell to create Document Sets, Delete Document sets etc, but not add files to an existing document set.

 

 @VesaJuvenon @ErwinVanHunen

 

Thanks

 

Nigel

5 Replies
Highlighted

Hi @Nigel Price,

 

Have you tried adding the fiels in the same way as you would do with a folder?

 

So with Add-PnPFile something like this:

 

PS:> Add-PnPFile -Path .\sample.doc -Folder "Shared Documents/DocumentSetName"
Highlighted

Try in the below format, specify the document set as <Library Name>/<Document Set Name>

 

Add-PnPFile -Folder "Shared Documents/docsetfolder1" -Path "C:\test1.xml"
Highlighted

Thanks @NarasimaPerumal Chandramohan @Pieter Veenstra for the responses.  Works good.

Highlighted

NarasimaPerumal,

 

I have tried your suggestion, with my substitutions:

Add-PnPFile -Folder "Shared Documents/documents" -Path "C:\temp\NormalFileName.txt"

 

and get the error:  Add-PnPFile : Local file was not found.

 

Yet I can see the file in Windows Explorer. 

 

I am trying to get a Powershell script working to load files in a hard drive/file share to SharePoint Online.

Highlighted

First of all, make sure that you connected to the correct site.

Secondly,  try this code. Path is a positional parameter:

Add-PnPFile -Path "C:\temp\NormalFileName.txt" -Folder "Shared Documents/documents"