KB10108 - PS: Create a scheduled task to run a PowerShell script

General description

  1. Create a task
  2. Run powershell.exe in the task
  3. assign a commandline to powershell.exe


This article assumes, that the user has administrative rights on the target server. Also the right "logon as a batch job" is required - The task will add this right if required and if this right is not controlled with GPO or otherwise.

Step by step

  1. Open "Task Scheduler" console.
  2. Run "Create a task..."
  3. General Tab:
    (1) Add a Name for you task.
    (2) Add the user, that is going to run the task later on.
    (3) Switch this box to "Run whether use is logged on or not" to allow task execution without a logged on user.
    (4) Enable this box only, if administrative rights are required to execute the script.
  4. Triggers Tab:
    (2) Create a new trigger to run the task on time (or whatever is possible...).
    (3) Change the schedule for your script execution.
  5. Actions Tab:
    (2) Create a new action
    (3) Bowse for "powershell.exe" (eg.: "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")
    (4) Add the commandline:
    • -noprofile (means no windows user profile will be loaded)
    • -executionpolicy bypass (PowerShell execution policy will be ignored to run a unsigned script for example)
    • -file "C:/Script/MyPS.ps1" (Path + FileName of you powershell script)

    (5) Foldername in which to execute the script (eg.: This should be the script path)

  6. Save the task by clicking on "OK".
  7. Now you have to provide the username and password for the account that is going to execute the task.