If you want to run a Powershell script against SharePoint on a timely schedule the Windows Task Scheduler is fast an simple approach.
A simple example of this could be a SharePoint warm-up script which hits a number of sites on a regular schedule. However it is maybe not as straight forward to figure out the syntax for the Powershell command as you might think.
Run in CMD
The first step is to verify you can run the script from a command prompt. (you might want to start the command prompt as the account that is going to run the scheduled task).
1. Click start and type CMD, press enter.
2. Paste the following command and replace the script-path with the location of you own script.
Powershell -file "C:\PathToFile\SharePointWarmupScript.ps1"
3. Press enter and see the script being executed successfully.
Create Task Schedule
The next step is to create the scheduled task.
1. Click start and type Task Scheduler, press enter.
2. Left click Task Scheduler and click Create Task.
3. Give the task a name, ex. SharePoint Warmup Task.
4. Select your desired options on the Triggers tab.
5. On the Actions tab click New and type the following.
Program/Script: Powershell
Add arguments (optional): -file "C:\PathToFile\SharePointWarmupScript.ps1"
6. Click OK to create the task.
The scheduled Powershell task is now created and you can test it out in the Task Scheduled Library if you like.
Comments
Post a Comment