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.

Advertisements

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 Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: