When trying to execute a PowerShell script, users may encounter the error:
File ABC.ps1 cannot be loaded because the execution of the script is disabled on this system
The first step is to check the Default Execution Policy by running PowerShell in administrator mode and typing:
Get-Execution Policy
The user may realize that it is restricted by default and that the error can be resolved by typing:
Set-Execution-policy remotesigned
The error will allow user-defined unsigned scripts or signed scripts from the internet to run. This command, however, sets permissions for all users to remotesigned
.
A better implementation would be to set permissions for only the current user as remote signed, bypass, or unrestricted by typing:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
This method is better because only the current user will have the permissions to execute the script, and it minimizes the chances of the system getting infected.