Sunday, July 4, 2021

PowerShell - Solution to “Running Scripts Is Disabled On This System” Error On Powershell

 While I was trying to create a virtual environment in VS code with PS, I got below error:


Error:

.\env1\Scripts\activate.ps1 : File C:\Users\abc\Desktop\python\script\inheritance\env1\Scripts\activate.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.

At line:1 char:1

+ .\env1\Scripts\activate.ps1

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : SecurityError: (:) [], PSSecurityException

    + FullyQualifiedErrorId : UnauthorizedAccess


Solution:

Step1 : Open windows in powershell as admin.

Open the Start menu on Windows and search for powershell and right-click on it. Click on “run as administrator”.

Step2: run below command:

set-executionpolicy remotesigned

Step3: You will be prompted to run accept the change, type Y(Yes) and press enter on your keyboard to allow the change.

Step4: When you are done, you can set the policy back to its default value with:

Set-ExecutionPolicy Restricted



No comments:

Post a Comment

Featured Post

OIC - How to Retrieve Email Attachments Using Microsoft Graph API: Automating Payment File Processing

Retrieving Email Attachments Using Microsoft Graph API: Automating Payment File Storage in Object Storage Use Case: A finance team needs t...