How to Upload files to a SharePoint Document Library using PowerShell Script

# create the Variable Path and Pass the source folder path

$path = “D:\Source File\”;

# create the Variable destination and pass the URL of the SharePoint List

$destination = “http://projectserver14:99/PWA/SharePointListURL/“;

# Store the current user default credentials in the Variable Credentials

$credentials = [System.Net.CredentialCache]::DefaultCredentials;

# Create the object of the Webclient

$webclient = New-Object System.Net.WebClient;

# Pass the user credentials

$webclient.Credentials = $credentials; Get-ChildItem

# “For Each” loop will upload all of the files one by one onto the destination using the UploadFile method

Get-ChildItem $path | ForEach-Object { $webclient.UploadFile($destination + “/” + $_.Name, “PUT”, $_.FullName)};

Note: User need to have an access to the SharePoint list to upload the documents.

2 thoughts on “How to Upload files to a SharePoint Document Library using PowerShell Script

  1. manojhirway August 30, 2013 at 8:44 am Reply

    Thanks. The upload was so quick !

  2. jamesqmurphy May 7, 2014 at 8:32 pm Reply

    I agree… and this was the first solution I found that did not require the PSSnapin. Very nice. Just what I needed. Thanks!

Leave a comment