This PowerShell tutorial, we will discuss how to solve PowerShell cannot be loaded because the execution of scripts is disabled issue, which comes while running PowerShell cmdlets in Windows 10 machine.
Recently I was trying to run a PowerShell command using PowerShell ISE, but it gave an error:
cannot be loaded because running scripts is disabled on this system like below:
PowerShell cannot be loaded because the execution of scripts is disabled
The error was coming because the PowerShell execution policy doesn’t allow to run scripts by default in the Windows 10 laptop.
By default, the PowerShell policy was set to Restricted which means No scripts can be executed.
To allow script execution, we need to use the Set-ExecutionPolicy PowerShell cmdlets. Run the cmdlet like below:
It will show you a confirmation box, select Yes to All and then when you run any cmdlets in PowerShell, it will run successfully like below:
To run outside script set Set-ExecutionPolicy to RemoteSigned like:
Below are the different types of policy we can set for PowerShell.
- Restricted: You can run any script, no script is allowed to run.
- Unrestricted: All Windows PowerShell scripts can be run.
- AllSigned: Only trusted publisher scripts are allowed to run.
- RemoteSigned: Downloaded scripts must be signed by a trusted publisher.
If you want to know what is current policy set, then you can run the below PowerShell cmdlets.
You can bypass this policy by adding -ExecutionPolicy ByPass when running PowerShell
powershell -ExecutionPolicy ByPass -File myscript.ps1
If you wanted to change the policy to RemoteSigned/Unrestricted for just the CurrentUser, you can run the below PowerShell cmdlets.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser or Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "Unrestricted" or Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
You may like following PowerShell tutorials:
- The remote server returned an error: (403) Forbidden
- PowerShell reference variable
- Working with PowerShell Date Command (Get-Date)
- What is a PowerShell Variable
- How to check if file created last 24 hours using PowerShell?
- How to create and use PowerShell global variable
- Create a folder if not exists using PowerShell
- PowerShell create an encrypted password file and use in SharePoint online
- Create a file if not exists with name as today’s date using PowerShell
- How to check file size using PowerShell Script [Easy Way]
- Get SharePoint document library size using PowerShell
- PnP PowerShell commands for SharePoint Online Site
This PowerShell tutorial, we learned how to solve cannot be loaded because running scripts is disabled on this system error which comes in windows 10 while running PowerShell cmdlets.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site EnjoySharePoint.com