There are many cases, when we get an error “ps1 cannot be loaded because the execution of scripts is disabled on this system” while executing any script in Windows Powershell. It is well understood that the execution policy helps to protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks. But we still want to change it since, we want to run our scripts or commands in powershell at least for current logged in permissible user.
One point to be noted here is an assumption that you are an administrator of your machine. Trust me, it doesn’t matter of being an administrator, powershell is still not allowing you to execute your commands.
Let’s take example of creating SharePoint Framework (SPFx) component, we want few commands to be executed on powershell like:
Everytime we provide these commands (e.g. nodejs or npm packages) to Powershell, it throws as below:
How to resolve this problem?
To fix this problem, let’s first check existing execution policy in the machine. Run below command in powershell.
Now we’ll change execution policy for CurrentUser who is administrator of system as well. Run the following command in powershell.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
You can the changes by running below command.
Lets continue to your work now, create a SharePoint Framework (SPFx) project
Because you are unrestricted now, you can continue to your work as usual. Let’s check if powershell is executing our provided commands or scripts.
Yes, it is working now.
- What is SharePoint Framework (SPFx)
- Future prospects of SharePoint Framework (SPFx)
- Must Read: Tips & Tricks Guide
- Required tools and libraries for SharePoint Framework (SPFx) development
- Setup Office 365 tenant for SharePoint Framework development
- Setup SharePoint Framework client side web part development environment
- Build SharePoint client side web part using SharePoint Framework (SPFx) – I
- Build SharePoint client side web part using SharePoint Framework (SPFx) – II
- Don’t Forget to View: How-to Guide
- Build SharePoint client side web part using SharePoint Framework (SPFx) – III
- How to Debug SharePoint Framework Solutions in Visual Studio Code
- What is the Developers Point of View on SharePoint Framework
- What is Required Toolchain for SharePoint Framework
- How to Integrate gulp tasks with SharePoint Framework Toolchain
- How to Provision SharePoint assets with solution packages
- How to Upgrade SharePoint Framework client side solutions in SharePoint Online
- Project Management Tutorial
THREE QUERIES offers easy access to information about SharePoint and associated technologies, project management, agile and scrum methodologies that helps developers, administrators, architects, technical managers, business analysts and end users. It has grown from there. We provide an important knowledge base for those involved in managing, architecture and developing software projects of all kinds. With weekly/daily exclusive updates, we keep you in touch with the latest business, management, technology thinking.
WE ARE CONNECTED ~ Follow us on social media to get regular updates and opinion on what's happening in the world of SharePoint, front-end, back end web technologies and project management. If you like this article, please share it and follow us at Facebook, Twitter, Instagram, Pinterest and LinkedIn