b

How To Execute/Schedule PowerShell Script Using Task Scheduler

Query King | Tue, 11 Jul 2017 at 15:40 hours | Replies : 2 | Points : 100

Category : Windows Server 2008


How to execute/Schedule PowerShell script using Task Scheduler


This Question is already solved Click To See The Answer


Hi King,

Kindly follow the below steps to schedule the PowerShell file:

1- Open the task scheduler (Start -> All Programs -> Accessories -> System Tools -> Task Scheduler

2- Click op Create Basic Task


3- Type a name and description for your task


4- Choose your trigger


5- And configure your trigger


6- Configure the action "Start a program"


7- The program to start is Powershell

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

 

     with the arguments:

    -command "& 'D:\yourfilewithcommands.ps1' "

 

    UPDATE:

    If you don’t like to change the execution policy for the computer you can use:

    -ExecutionPolicy Bypass -file "D:\yourfilewithcommands.ps1"

 

8- Click the open the properties window checkbox to set extra options


9- Select the Run wheter user is logged on on not option and check the Run with highest privileges checkbox, don’t forget to select the correct user!


10- On the Triggers tab you can fine tune your schedule to repeat the schedule every hour, 10 minutes or whatever


11- Save the Scheduled task and now you can run it manually (or wait for it to run automatically if you like) to test it.

Now you have a scheduled powershell script.

Hi Rohit,

 

Thanks a lot for details and step by step solution :)