Home » How To » How to Run PowerShell Script on Startup

How to Run PowerShell Script on Startup

If you use PowerShell scripts for Windows automation or administration, such as checking for Windows updates, network management, data manipulation, etc., having it run when the computer starts is incredibly useful. In this article, we’ll show you two simple ways to run a PowerShell script on Windows startup. Let’s get started.

Note: Before proceeding, make sure you change the PowerShell’s execution policy to remote signed or unrestricted. Otherwise, the scripts might not run due to policy restrictions.

Add PowerShell Script to Windows Startup

The easiest way to run a PowerShell script as soon as the computer starts is by adding the script to the startup folder. Here’s how to do it.

First, press Windows key + R to open the run dialog box. In the dialog window, enter shell:startup and click OK to open the Windows startup folder.

open startup folder using shell startup run command

In the startup folder, right-click and select New and then Text Document to create a new text file. After that, double-click on the text file to open it in Notepad.

create and open text file

Once it opens, paste the following command while replacing the example path with the actual path of your PowerShell script. After that, press Ctrl + S to save the file and then close it by clicking the X button on the title bar.

powershell "C:\path\to\powershell\script.ps1"

add command to start PowerShell script at startup

Now, select the file, press F2 on your keyboard, rename the text file to ‘psstartup.cmd‘ and press Enter. Click Yes in the confirmation window. You can change the file name to whatever you want, just make sure that you change the file extension from .txt to .cmd.

rename the text file to cmd file

Note: If you don’t see the file extension, ensure your file explorer settings show file extensions.

That’s it. Close the Startup folder window and you are good to go. From now on, the PowerShell script will run automatically on startup.

Use Task Scheduler to Run PowerShell Script When Computer Starts

As an alternative, you can also schedule the PowerShell script to run on startup. This method is particularly useful if your script requires administrative privileges.

First, click on the Windows logo, search for Task Scheduler in the Start menu, and click on the top result to open the Task Scheduler application.

open task scheduler from start menu

Once it opens, click on the Create Basic Task option on the right sidebar.

click create basic task

Enter a name of your choice in the Name field and click Next.

enter a name of the scheduled task

In the Task Trigger window, choose When the computer starts option and click Next.

select when computer starts option

Choose Start a program in the Action window and click Next.

select start a program

In the Start a Program window, enter powershell.exe in the Program/Script field and add the path to your PowerShell script file in the Add arguments field. Click Next to continue.

add PowerShell script to task scheduler

Click the Finish button to complete creating the scheduled task.

click finish

(Optional) If your PowerShell script requires administrative privileges, find the scheduled entry in the task scheduler’s window, right-click on it, and choose Properties. Next, navigate to the General tab, select the Run with highest privileges checkbox, and click OK.

select run with highest privileges checkbox and click finish

That’s it. From now on, Task Scheduler will automatically run the PowerShell script on system startup. Optionally, you can also delay the scheduled startup if you don’t want to slow down your system or increase the startup time.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top