相关疑难解决方法(0)

VSCode 覆盖 PowerShell 执行策略

在 VSCode for PowerShell v5 x64 和 x86 中使用时,Get-ExecutionPolicy -list它返回以下内容:

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process          Bypass
  CurrentUser       Undefined
 LocalMachine       Undefined
Run Code Online (Sandbox Code Playgroud)

当在 VSCode 中使用相同的命令并使用 PowerShell v7 控制台时,它会返回:

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process    RemoteSigned
  CurrentUser       Undefined
 LocalMachine    RemoteSigned
Run Code Online (Sandbox Code Playgroud)

有 2 个注册表项设置 ExecutionPolicy(最初:ByPass)

HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command      REG_SZ  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process RemoteSigned }; & '%1'" 
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Microsoft.PowerShellScript.1\Shell\0\Command        REG_SZ  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process RemoteSigned }; …
Run Code Online (Sandbox Code Playgroud)

registry powershell visual-studio-code

3
推荐指数
1
解决办法
6528
查看次数

重新启用导入模块 Psreadline 警告

这个警告在 Visual Code 应用程序的终端中不断弹出

Warning: PowerShell detected that you might be using a screen reader and has
         disabled PSReadLine for compatibility purposes.
         If you want to re-enable it, run 'Import-Module PSReadLine'.
Run Code Online (Sandbox Code Playgroud)

即使我将值更改为0via regedit,警告仍然显示。

powershell warnings screen-readers visual-studio-code

3
推荐指数
1
解决办法
2568
查看次数

尽管 Windows 终端可以找到,但 VS Code 终端无法找到 AWS SAM

我通过适用于 Windows 的 AWS 的 msi 安装程序安装了 AWS SAM。运行安装程序后,我sam --version在cmd和powershell中运行。

PS C:\Users\dgupta> sam --version
SAM CLI, version 1.26.0
Run Code Online (Sandbox Code Playgroud)

它返回我刚刚安装的版本。然而,在 VS Code 中,我打开了一个终端并运行sam --version它,结果出现错误。

PS C:\Users\dgupta> sam --version
SAM CLI, version 1.26.0
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况?VS Code 终端和普通终端不能访问相同的环境变量吗?

windows powershell path-variables visual-studio-code aws-sam-cli

3
推荐指数
1
解决办法
6011
查看次数

如何在 Visual Studio Code 中以 noprofile 的形式启动 Powershell 脚本

如何在 Visual Studio Code 中将 Powershell 脚本作为 noprofile 启动,我可以使用命令PowerShell_Ise -NoProfile运行带有 noprofile 的 Powershell Ise 。但是我们如何在 Visual Studio Code 中为 poershell 会话做同样的事情。

shell powershell visual-studio-code

2
推荐指数
2
解决办法
1956
查看次数