0

I'm trying to run a .ps1 file from Developer Powershell for VS 2019 and this is what I get:

PS C:\Users\name\Documents\GitHub\proj> ./test.ps1
./test.ps1 : File C:\Users\name\Documents\GitHub\proj\test.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
+ ./test.ps1
+ ~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

I've followed the steps at https://stackoverflow.com/a/68381260 and I can run a .ps1 file in normal PowerShell, just not in Developer Powershell for VS 2019. Is there some trick to this, or it blocked for a reason? This is the output of Get-ExecutionPolicy -List from Developer Powershell for VS 2019:

PS C:\Users\name\Documents\GitHub\proj> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined
8
  • Does this answer your question? PowerShell says "execution of scripts is disabled on this system." Commented Jan 22, 2024 at 5:20
  • @KenWhite no - my issue is in Developer Powershell for VS 2019 specifically. Commented Jan 22, 2024 at 5:22
  • Did you execute Set-ExecutionPolicy in your developer PowerShell or in your regular PowerShell? Commented Jan 22, 2024 at 8:16
  • Developer PowerShell is still PowerShell, and policy execution permissions are set exactly the same way in both, which means that the link I provided does in fact apply. Commented Jan 22, 2024 at 14:21
  • 1
    If you do not want to mess with execution policies, just execute powershell -ExecutionPolicy ByPass -File ./test.ps1 instead of ./test.ps1. Commented Jan 23, 2024 at 6:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.