Vue create cannot be loaded because running scripts is disabled on this system

I design websites in VSC and PowerShell is my default terminal.

After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immediately after I cannot run/access any firebase scripts wthout the folllowing error:

firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1

firebase
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

I've spent a few hours searching around and can't find a solid answer the problem. Many threads are several years old and I find it bizarre I've not had this problem in the past year until today.
I can still access firebase scripts if I set my default terminal to cmd.

Assuming the problem was related to firebase-tools I've carried on working but have now updated vue.js and get the error again when trying to run any vue commands in powershell:

vue : File C:\Users\mada7\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1

vue
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

VSCode Version:
Version: 1.37.1 (user setup)
Commit: f06011a
Date: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362
OS Version:
Windows 10 Home
Version - 1903
OS build - 18362.295

I've been reading around and seen many threads around permissions for scripts, but I haven't changed any - indeed the PowerShell scripts worked right up until I updated my packages. No other settings touched in the mean time. I don't want to be changing PowerShell settings unnecessarily.


Since I intensively started using Visual Studio Code across my devices, with PowerShell as my main terminal, I started running into the following error quite a lot:

<file> cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

What’s happening here, is that your computer is preventing you from running potentially harmful scripts. This safety mechanism can broadly be configured on three levels: for your computer, for a user or for a particular session. These safety mechanisms are execution policies.

It’s good to know that you can bypass this safety mechanism by copying the code from a script and running it manually in a PowerShell terminal. So execution policies do not block the code, but they make sure you don’t unintentionally run malicious scripts.

However, there’s a more conventional way. You can relax the execution policies, by taking these simple steps.

  1. Press the windows-button on your keyboard.
  2. Type ‘PowerShell’
  3. Right-click Windows PowerShell
  4. Click Run as Administrator
  5. Run the following command and confirm with ‘Y’
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

We have changed the execution policies to allow local and remote signed scripts and we have done this for the scope of your machine. Conclusion: You can now run PowerShell scripts on your computer.

Great success!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Can't run scripts in Azure Active Directory Module for Windows PowerShell

  • Article
  • 04/20/2022
  • 2 minutes to read

In this article

This article describes an issue in which you receive an error message when you try to run scripts in Azure Active Directory Module for Windows PowerShell.

Original product version:   Azure Active Directory, Microsoft Intune, Azure Backup, Office 365 User and Domain Management, Office 365 Identity Management
Original KB number:   2411920

Symptoms

When you try to run a script in Microsoft Azure Active Directory Module for Windows PowerShell, you receive one of the following error messages:

File C:\my_script.ps1 cannot be loaded. The execution of scripts is disabled on this system. Please see "Get-Help about_signing" for more details.

File C:\Desktop\myscript.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

File C:\my_script.ps1 cannot be loaded. The file C:\my_script.ps1 is not digitally signed. The script will not execute on the system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.

Cause

This issue may occur if one of the following factors is true:

  • The PowerShell version that you are using is higher than 5.1. The Azure Active Directory Module only works with PowerShell 3 to 5.1.
  • The execution policy is set to Restricted. Certain Windows PowerShell cmdlets can't run if the policy is too restricted.

Resolution

To resolve this issue, follow these steps:

  1. Identify the PowerShell version by running $PSVersionTable.

  2. Run the Azure Active Directory Module for Windows PowerShell as an administrator. To do it, select Start, select All Programs, select Windows Azure Active Directory, right-click Windows Azure Active Directory Module for Windows PowerShell, and then select Run as administrator.

  3. Set the execution policy to Unrestricted. To do it, type the following cmdlet, and then press Enter:

    Set-ExecutionPolicy Unrestricted
  4. Run the Windows PowerShell cmdlets that you want.

  5. Set the execution policy to Restricted. To do it, type the following cmdlet, and then press Enter:

    Set-ExecutionPolicy Restricted

More information

To help deliver a more secure command-line administration experience, Windows PowerShell uses "execution policies" to control how Windows PowerShell can be used. Execution policies define the restrictions under which Windows PowerShell loads files for execution and configuration. Windows PowerShell runs in the Restricted execution policy by default. This mode is its most secure mode. In this mode, Windows PowerShell operates as an interactive shell only.

The four execution policies are as follows:

  • Restricted is the default execution policy. This policy doesn't run scripts and is interactive only.
  • AllSigned policy runs scripts. All scripts and configuration files must be signed by a publisher that you trust. This policy opens you to the risk of running signed but malicious scripts, after you confirm that you trust the publisher.
  • RemoteSigned policy runs scripts. All scripts and configuration files downloaded from communication applications must be signed by a publisher that you trust. These communication applications include Microsoft Outlook, Windows Internet Explorer, Outlook Express, and Windows Messenger. This policy opens you to the risk of running malicious scripts that aren't downloaded from these applications. And you aren't prompted in this situation.
  • Unrestricted policy runs scripts. All scripts and configuration files downloaded from communication applications run after you confirm that you understand that the file originated from the Internet. These communication applications include Outlook, Internet Explorer, Outlook Express, and Windows Messenger. No digital signature is required. This policy opens you to the risk of running unsigned, malicious scripts that are downloaded from these applications.

If you have questions or need help, create a support request, or ask Azure community support.

Feedback

Submit and view feedback for

How do you fix Cannot be loaded because running scripts is disabled on this system?

Solution for “cannot be loaded because running scripts is disabled on this system“:.
Open PowerShell Console by selecting “Run as Administrator” and set the execution Policy with the command: Set-ExecutionPolicy RemoteSigned..
Type “Y” when prompted to proceed..

Why is running scripts disabled on my system?

While running PowerShell script, if you get running scripts is disabled on this system, it is because the PowerShell execution policy is set up by default as Restricted and doesn't allow to run script. PowerShell has built-in security features implemented.

How do I enable scripts in Windows 11?

How to Enable Running Scripts in Windows 11/10.
Step 1 : Go to your start menu and type “cmd”. ... .
Step 2 : Type in the first command promt “Get-ExecutionPolicy -List” and hit Enter..
Step 3 : Type in the second command “Set-ExecutionPolicy Unrestricted” and hit Enter again..
Step 4 : ... .
Step 5 :.