Primary Menu

Schedule a PowerShell Script to run on Windows Startup

By default, ps1 files open with the default text-editor. So mere putting it in the startup folder will only open the file at the startup instead of them actually getting executed. In order to execute the same, we need to trigger a startup job which will fire the PowerShell in the non-interactive mode with the file path as argument. Following are the steps:* Open the Windows PowerShell in admin mode.

* Create a new job trigger. Here, I am introducing a delay of 10 mins.

View the scheduled job

* Open Task Scheduler and navigate to Microsoft => Windows => PowerShell. You can find here, the newly scheduled job.

* Open its properties. Since, the script will check the state of some Windows Services on startup. I’ll select the ‘Run with highest privileges‘ option.

* Go to the Action tab and select Edit Action. Here, you can see that it’s the PowerShell, which will be fired at the startup, and it contains the script path as argument along with some other properties.

* Finally, at the time of saving, admin password box will be prompted. This is because, I have marked the job to run with the highest privileges.