PowerShell is an automation engine that helps users in task automation. Recently, many people reported that they are experiencing problems while running a script in PowerShell.
According to the user reports, the system throws the following error message in that case.
testscript.ps1 cannot be loaded because running scripts is disabled on this system.
The error basically occurs because of a security measure implemented in the Windows OS. The system does not allow any script to run on your system without administrative permissions. You need to follow the steps listed in this article to troubleshoot the running scripts is disabled on this system error.
How to fix PowerShell Running scripts is disabled on this system?
1. ByPass the Execution Policy
- You can update the command to get access to the script access via policy.
- Open the run dialogue by pressing Windows+R keys.
- Type Powershell in the textbox and simultaneously press Ctrl + Shift + Enter keys. This process will run PowerShell as an administrator.
- Now you can type the following command to execute a specific PowerShell script: c:> powershell -ExecutionPolicy ByPass -File testscript.ps1
- Finally, hit the enter key and check if your system successfully runs the script.
Note: This solution will bypass the Execution Policy to run the script on your system. Move on to the next solution if you don’t want to bypass the default policy.
2. Change the Execution Policy
- Simultaneously press the Windows + R combo to open the run dialogue box.
- Once the dialogue box opens on your screen, type Powershell and press Ctrl + Shift + Enter keys to open PowerShell with administrative access.
- Based on your particular situation, Windows allows you to set the policy to four different modes. To get the List of Execution Policy, you can type the command: Get-ExecutionPolicy -List
- Press the Enter key and you will now see a list showing the Execution Policy status for all the User Groups.
- Check the status of LocalMachine under the scope column.
- If the execution policy is set to Restricted or Undefined, you need to set the Execution Policy to Unrestricted.
- Type the following command to change the status in the PowerShell window: Set-ExecutionPolicy RemoteSigned
- Press the Enter key to execute the command and then Y to confirm the change.
- If the problem still persists, replace RemoteSigned with Unrestricted.
Note: The RemoteSigned Execution Policy restricts your system from running those scripts that are not signed by a trusted publisher. However, the restriction is removed if you choose Unrestricted.
If you found our solutions helpful, do let us know in the comments section below which one of them worked for you.Editor's Note: This article was originally published in September 2019 and was revamped and updated in May 2020 for freshness, accuracy, and comprehensiveness.