If you trying to run a script in Windows 10 PowerShell and you receive the error message "Cannot be loaded because running scripts is disabled on this system" continue reading below to fix the problem.
How to FIX: Cannot Run PowerShell Script because Security Policy Prevents scripts from running in Windows 10.
The PowerShell error "%ScriptName%.ps1 cannot be loaded because is disabled on this system", appears because of a security policy that prevents scripts to be running. To remove the restriction and enable running scripts in Windows 10, proceed as follows:
1. Open PowerShell as Administrator. To do that:
2. At PowerShell copy/paste the command below and press Enter:
- Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
3. Press Y and hit Enter at execution policy warning message to accept the change..
4. After the policy change is completed, close the PowerShell window.
5. Now, run the script that gave you the error "Scripts is Disabled" with admin privileges. The error should be gone now. *
* Note: If you still receive the error "Scripts are disabled on this system", give one of the following commands and try again to run your script:
- Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
- set-executionpolicy remotesigned
6. Finally, revert back to the previous PowerShell execution policy setting (restriction), by running this command in PowerShell (Admin): *
- Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Restricted
* Note: After running the above command, you'll receive a warning message that explains the security risks of an execution policy change. Press Y, and then press Enter to accept the change and revert to your previous policy setting.
7. Close the PowerShell window and you're done!
That’s all folks! Did it work for you?
Please leave a comment in the comment section below or even better: like and share this blog post in the social networks to help spread the word about this solution.