If you have ever encountered the need to run scripts in Windows 10 or a Windows server, for example to automate some tasks such as sending an email when a user enters an account or tasks related to Microsoft 365 and its automation with users, most likely you have skipped an error in the console and were unable to run said script.
The error is usually a message that appears:
“No se puede cargar el archivo C:UsersArturoDocumentsFirst Script.ps1 porque la ejecución de scripts está deshabilitada en este sistema. Para obtener más información, consulta el tema about_Execution_Policies en https:/go.microsoft.com/fwlink/?LinkID=135170.”
This error is normal because running scripts can be dangerous and are disabled by default. For this reason, administrator level permissions are required and the option to run scripts in Windows is required.
In order to fix this problem, we need to change the permissions of the current user. To do this, we will go into the PowerShell as administrators, we will run the following command and accept the change:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Basically, this command allows executing locally created scripts with remote signing. However, scripts created on another machine or by another user will only be executed if they are signed by a trusted editor. We have selected this option because we believe it is the best in terms of security, but you can check out the different options in the Microsoft website.
Once this change is made, through the Windows PowerShell terminal, we will see that it now allows us to run the script that initially gave an error. In our case, we see that the string “Hello, World!” appears on the screen:
With this we have solved the problem and we can start programming!