When a user logs on or starts up the computer, all the scripts run simultaneously. It may cause some delay in the startup or running a specific program. It is often required to run all the Windows PowerShell scripts and Group Policy Object to run before non-PowerShell scripts.

Run Windows PowerShell scripts first

To run Windows PowerShell scripts first at user logon, logoff, startup, and shutdown, follow these steps- Let’s check out these steps in detail. At first, you will have to open the Local Group Policy Editor. For that, press Win+R, type gpedit.msc, and hit the Enter button. After opening it, navigate to the following path- You will see two settings called:

Run Windows PowerShell scripts first at user logon, logoff,Run Windows PowerShell scripts first at computer startup, shutdown.

Double-click on each of them, and select the Enabled option.

Click the Apply and OK to save the change.

Run Windows PowerShell scripts first at user logon, logoff, startup, and shutdown using Registry Editor

To run Windows PowerShell scripts first at user logon, logoff, startup, and shutdown using Registry Editor, follow these steps- To know more, keep reading. Before getting started, it is recommended to backup all Registry files and create a System Restore point. Press Win+R to open the Run prompt, type regedit, and hit the Enter button. If the UAC prompt appears, click the Yes button. After that, navigate to this path- Here you will have to create two REG_DWORD values. For that, right-click on System > New > DWORD (32-bit) Value and name it as RunUserPSScriptsFirst.

Double-click on it and set the Value data as 1.

Follow the same steps to create another DWORD (32-bit) Value and name it as RunComputerPSScriptsFirst. Then, set the Value data as 1. RunUserPSScriptsFirst represents the Run Windows PowerShell scripts first at user logon, logoff setting, whereas RunComputerPSScriptsFirst defines the Run Windows PowerShell scripts first at computer startup, shutdown setting. In case you want to revert these changes, you can follow these steps. If you have done it using the Local Group Policy Editor, open the same path and select the Not Configured option. If you have done it using the Registry Editor, open the same System key and delete those two REG_DWORD values. To remove them, right-click on each of them, select the Delete option, and confirm it by clicking the OK button. Hope it helps.