Run a Powershell Script with Task Scheduler

Powershell gives you many options to administrate your farm, but it also can help you to get certain jobs done regularly. In one of my customer projects it was necessary to copy a certain document from library A to library B each month on the same day.

We created therefore a small powershell script which does the job including logging. Now we added it to the windows task scheduler and configured it for our needs. In the action tab we added an action which starts a program. We typed in there powershell and added the powershell script as parameter.

Parameter: -file “C:\Users\pohnke\Downloads\CopyFileToAnotherLibrary.ps1”

psTask1

That’s all. The solution is simple and it took only a few minutes to get a working solution.

Another possibility would have been to develop a timer job in SharePoint with all following processes: Development, Testing, Install on Staging, Testing, Install on Production, Testing, Documentation, etc. which would take hours.

Great to have Powershell.

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.


*