Tuesday, December 23, 2014

Run a PowerShell script in windows scheduler

Once I had a client requirement to run a PowerShell script for a SharePoint 2010 web application to download web analytic reports in a scheduled time. This is how I scheduled the automation of PowerShell script

1.       Go to task scheduler
2.       Click in “Create Task”

3.       Give a name to the task
“Generate Web Analytic Reports”

4.       In Triggers tab, give the date and time which need to Schedule the task


5.       In Actions tab add a new Action
·         Select the Action as “Start a program”
·         In “Program/Script” text box give the following path


C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

·         In “Add Arguments (optional)” text box add following


-psconsolefile "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\psconsole.psc1" -command "C:\ShawCor\WebAnalitics\Reports.ps1"


Report.ps1 is the PowerShell script which I need to run

·         Then click OK

Click Ok to set the task scheduler. The script will run at the given date and time.

No comments:

Post a Comment