SharePoint PowerShell Script Scheduling

4.50 avg. rating (90% score) - 2 votes

SharePoint PowerShell Script are very powerful set of tools using which administration/management has become quite flexible. I came across a scenario where certain workflow needs to be invoked after a certain time period elapses on a document. The purpose of the workflow was to auto-approve the document after a certain time period has been elapsed and no action has been taken by the user.

There were options to either write down some complex code logic or use PowerShell script. I choose to write a few lines of SharePoint PowerShell script to do the trick. Once that was done, next thing was to schedule it so that it executes daily and looks at the documents which needs to be approved by the system. Again there  were two options either to use the timer jobs again handful of custom code or to use the Windows Task Scheduler.

I decided to sue the task scheduler, but there was a little catch in it. The problem is that we cannot directly call .ps1 file in task scheduler. The reason is that the SharePoint PowerShell script executes with a plug-in pre-loaded into the PowerShell environment before it can get executed. So in order to schedule this activity we need to load that plug-in. In the task scheduler task window, this is how we should actually can do it:

powershellscript

The key is to add the required snap-in before calling the .ps1 script. Once that is done, you are well on the target using the magic’s of PowerShell script.

4.50 avg. rating (90% score) - 2 votes

W@rfi

Owner of this blog site. Have expertise on Microsoft technologies.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *