Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi Friends,

I have a few files on a network location which i to need overwrite to a SharePoint Document Library, this should happen daily on a specific time.

I am new to SharePoint, so please provide me the details steps if possible.

Thanks in Advance
Updated 19-Apr-14 22:41pm

1 solution

You can use a PowerShell script and schedule it using Windows Scheduler to run at a specific time every day.

People would argue to use SP Timer Jobs, but having the good old Scheduled jobs makes it cloud ready considering Microsoft shift to Office 365 where you can not run a Full Trust solution.

This script should help:

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
     Add-PSSnapin Microsoft.SharePoint.PowerShell;

#Site Collection where you want to upload files
$siteCollUrl = "http://SPWebApplication/sites/Upload" 
#Document Library where you want to upload files
$libraryName = "Shared Documents"
#Physical/Network location of files
$reportFilesLocation  = "C:\Users\manas\Desktop\File"

$spSourceWeb = Get-SPWeb $siteCollUrl;
$spSourceList = $spSourceWeb.Lists[$libraryName];
if($spSourceList -eq $null)
	Write-Host "The Library $libraryName could not be found."

$files = ([System.IO.DirectoryInfo] (Get-Item $reportFilesLocation)).GetFiles()
foreach($file in $files)
	#Open file
	$fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
	#Add file
	$folder =  $spSourceWeb.getfolder($libraryName)
	Write-Host "Copying file $file to $libraryName..."
	$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
	#Close file stream
Write-Host "Files have been uploaded to $libraryName." 

[EDIT]: I just blogged about this question with more details. See here:[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900