
$TaskDescription = "Running PowerShell script from Task Scheduler" The task is performed with the NT AUTHORITY\SYSTEM privileges. In this example, we create a scheduled task that will execute the specific file containing PowerShell script during startup. In Powershell 2.0 (Windows 7, Windows Server 2008 R2), to create a scheduled task from PowerShell you can use the Schedule.Service COM interface (or update the PowerShell version). $Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument “-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File C:\PS\StartupScript.ps1" If you have a PowerShell Execution Policy enabled on your computer that prevents PS1 scripts from executing, you can run a PowerShell script from a scheduled task with the –Bypass parameter. Your PowerShell script will run on the specified schedule. If the task was created successfully, the status “Ready” appears. Register-ScheduledTask -TaskName "StartupScript1" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force $Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "C:\PS\StartupScript1.ps1" $Trigger= New-ScheduledTaskTrigger -At 10:00am -Daily The task will be executed with elevated privileges (checkbox “Run with highest privileges”) under the SYSTEM account.

This task should run the PowerShell script file C:\PS\StartupScript.ps1 at 10:00 AM every day.


Let’s create a scheduled task named StartupScript1. Suppose, we need to create a scheduled task that should run during startup (or at a specific time) and execute some PowerShell script or command.
