2

I'm using SharePoint Foundation 2010.

I have to make a PowerShell script that copies a structure found on a network share. Its all good except for one thing... I know how to make Document Library's and folders inside them, I also know how to upload files to the document library's BUT I can't find out how to upload a file to a folder inside a document library.

For clarification:
Document library
-Folder
-Folder -->Upload to this folder
-Folder

4

To create a Document library:

New-SPList -Web http://spwebaddress -ListTitle “Enter Title Here” -ListUrl “ListURL” -Description “Description” -Template “Document Library”

To upload to a folder within document library you should get the spfolder then add to it...

$folder=$web.GetFolder(“FolderName″)
$folder.Files.Add($folder.Url + “/” + $file.Name, [System.IO.Stream]$fileStream, $true)

References:

http://sharepointgroup.wordpress.com/2012/08/17/how-to-upload-a-file-to-sharepoint-document-library-with-powershell/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.