Upload bulk documents to SharePoint 2016 document library using PowerShell

Upload bulk documents to SharePoint 2016 document library using PowerShell

Here in this post we will discuss how we can upload bulk documents to SharePoint 2016 document library using PowerShell. The same PowerShell script also works fine in SharePoint 2013 also.

Here we will upload documents to default “Documents” document library which is there in SharePoint 2016. I have a folder in my local drive which contains few files. We will upload those files to SharePoint 2016 document library by using PowerShell.

Also read: Upload large files to SharePoint online document library using PowerShell csom

Below is the PowerShell script which you can run in PowerShell ISE.



function UploadDocuments($destination, $File)
{
$securePassword=ConvertTo-SecureString “Qwe@12345” -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential(“MYSP\Administrator”,$securePassword)
$webclient=New-Object System.Net.WebClient
$webclient.Credentials=$credentials
$webclient.UploadFile($destination+”/”+$File.Name,”PUT”,$File.FullName)
}

$destination=”http://mypc:29024/sites/HydTraining/Shared%20Documents/”
$fileDirectory=”E:\Users\Administrator\Desktop\FilesToUpload\*.*”
foreach($fileName in Get-ChildItem $fileDirectory)
{
UploadDocuments -destination $destination -File $fileName
Write-Output “Upload file ” $fileName
}

Write-Host “Documents uploaded successfully”

Once you run the script, you will see files will be uploaded to document library like below:

Upload bulk documents to SharePoint 2016 document library using PowerShell
Upload bulk documents to SharePoint 2016 document library using PowerShell

Hope this article will help you to upload documents to SharePoint 2016/2013 document library.


About Bijay Kumar

I am Bijay from Odisha, India. Currently working with a reputed organization in Bangalore. I am Microsoft Office Servers and Services (SharePoint) MVP (4 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.

View all posts by Bijay Kumar →

Leave a Reply

Your email address will not be published. Required fields are marked *