简体   繁体   中英

Visual Studio Code Unsigned Powershell Scripts

I started using Visual Studio Code for Powershell scripting. I'd like to turn off the check for unsigned code, but cannot find out how to do this. I have not found anything in the forums either.

you can adjust the policy by adding arguments to the powershell.exe command. for this, open the settings json file. then add the following line:

    "terminal.integrated.shellArgs.windows": "-ExecutionPolicy ByPass",

I solved by setting the policy as :

Set-ExecutionPolicy –ExecutionPolicy RemoteSigned

to the Visual code integrated environment running as administrator.

The following blog clearly lists the steps to solve it:

http://donovanbrown.com/post/Using-PowerShell-in-VS-Code

PowerShell's default settings help prevent malicious scripts from being run. By default you should / can run scripts on the VSCode integrated terminal.

To change PowerShell security settings open PowerShell with admin privileges and run the command:

Get-ExecutionPolicy -List

You should get a response like this:

        Scope ExecutionPolicy
    ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       RemoteSigned  
 LocalMachine       AllSigned

The CurrentUser is probably Undefined as well since you can't run scripts on your VSCode terminal.

To change that, run this command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Reopen the VSCode Terminal, it should be working now.

If you want more details, you can find a full docs here: https://docs.microsoft.com/es-es/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7

You would use the command Set-ExecutionPolicy to change the execution policy of your system. You'll need to do so from an administrative session. You can find the appropriate syntax by using the command help Set-ExecutionPolicy from a PowerShell prompt.

You can also find command references online, for example SS64 and Technet .

There's also a highly visible Q&A here on Stack Overflow with the same info.

Go to Select default shell

在此处输入图片说明

then select Command prompt instead of Windows power shell it will work

在此处输入图片说明

I started using Visual Studio Code for Powershell scripting. I'd like to turn off the check for unsigned code, but cannot find out how to do this. I have not found anything in the forums either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM