»Script execution is disabled on this system.» SOLUTION

SEOCOM is an agency specialising in traffic acquisition and conversion where we have been working with clients from all sectors for many years. Our services focus on search engine optimisation (SEO) and optimisation of paid campaigns, mainly on Facebook and Google.

Aligned with these areas, we work on analytics and conversion to generate more return for our clients. We also have a development team that gives us support at any stage of a project and allows us to streamline and help the client in the implementations.

To learn more about SEOCOM you can go to our website, and if you want to learn and read our posts you can go to our blog, which contains all kinds of very interesting articles.

If you have ever encountered the need to run scripts in Windows 10 or Windows server, for example to automate certain tasks such as sending an email when a user logs into an account or tasks related to Microsoft 365 and its automation with users, most likely you have jumped an error in console, and you have not been able to run the script.

The error is usually a message in which it appears:

"Cannot load the file C:\UsersersArturoDocuments.ps1 Script.ps1 because script execution is disabled on this system. For more information, see the about_Execution_Policies topic at https:/go.microsoft.com/fwlink/?LinkID=135170."

This error is normal as script execution can be dangerous and is disabled by default. This is why administrator-level permissions and enabling the script execution option in Windows is required.

In order to solve this, we must change the permissions of the current user. To do this we will go to the PowerShell as administrators, execute the following command and accept the change:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Basically what this command allows is to execute locally created scripts with a remote signature. On the other hand, scripts created on another machine or by another user will not be executed unless they have a signature from a trusted publisher. We have selected this option as we believe it is the best in terms of security, but you can consult the different options on the Microsoft website.

Once this modification has been made, using the Windows PowerShell terminal, we will see that the script that initially gave an error can now be executed. In our case, we see that the string «Hello, World!» is displayed on the screen:

With this, the problem is solved and we can start programming!