Home >Tips >PowerShell with SharePoint from Scratch >Upload files to SharePoint with scheduled task kalmstrom.com site map icon Site map  

Upload files to SharePoint Library with Scheduled Task

A PowerShell with SharePoint tutorial

PowerShell iconSharePoint has several methods to upload files from Windows Explorer to a document library, but if you want to do it automatically, you should use a PowerShell script.

In such a scenario, you can put all files that should be uploaded in a specific folder and then they will be uploaded to the SharePoint library of your choice when the script is run.

In the demo below, Peter will explain how to schedule a task that runs the script automatically. For that, he creates a "script running" task the Task Scheduler, which is included in Windows.

Peter uses the script from the previous article, where all copied files are moved to a subfolder so that they will not be uploaded to the library again.

Note that you need to use a certificate that allows modifications to SharePoint without login, if you want to run a PowerShell script that connects to SharePoint automatically. In an earlier article, we described how to create such a certificate.
  1. Copy the path to the .ps1 file that should run on a schedule.
  2. Open the Windows Task Scheduler.
  3. Create a new task. In the demo, Peter uses the Basic task option, but if you want to have more choices on when the task should be run you can create a standard task.
  4. Give the task a name.
  5. Set a Trigger for the task - that is, how often (and at what time) the task should be run. In the standard task creation you can set a few other parameters.
  6. Keep the default Action: Start a program.
  7. Enter pwsh for PowerShell 7.
  8. Enter the arguments –Noprofile -WindowStyle Hidden -ExecutionPolicy Bypass -File [paste the path you copied in step 1]
  9. Finish the task creation.
  10. Test the script by right-clicking on the task in the Task Scheduler and selecting Run.
In the next article, we will show how metadata can be included in the uploaded files.

back icon next icon
Products Buy FAQ Services Tips Books Contact About Us Tools

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved