Skip to main content

GPO: Enable script execution.

PowerShell script execution is disabled by default on domain-joined computers. If you attempt to run a script, you will receive a message stating that the policy is restricted.

Disallowed Scripts

alt text

alt text

As administrators, we may want to implement scheduled tasks to perform certain automations, so it is necessary to be able to run scripts without restrictions.

While it’s true that we can manually modify these values ​​within the computer or bypass the script as shown in the image.

alt text

Here we’ll show you how to modify this option from a GPO. To do this, follow these steps:

Creating a GPO

Go to Group Policy Management.

alt text

Create a new GPO.

alt text

Give it a suitable name that reflects its purpose.

alt text

Right-click on the new GPO and select Edit.

alt text

Expand User Configuration, Administrative Templates, Windows Components, and open Windows PowerShell.

alt text

Within Windows PowerShell, edit Turn on Script Execution.

alt text

Enable and select Allow all scripts in the combo box.

alt text

Once our new GPO is created, we can add it to our OU. Because this GPO is based on user configuration, we must add it to an OU where the users are located.

Assigning a GPO to an OU

Another thing we must consider is security. We shouldn’t allow all users to run scripts, so I will only apply this new GPO to the IT OU.

alt text

alt text

alt text

Now, if I run the script, I won’t have any problems.

alt text

Note!

Note: “For highly secure production environments, it is recommended to sign scripts and use ‘AllSigned’, but for labs or internal IT automation, ‘Allow all’ is sufficient.”