在 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) 这个警告在 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)
即使我将值更改为0
via regedit,警告仍然显示。
我通过适用于 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
如何在 Visual Studio Code 中将 Powershell 脚本作为 noprofile 启动,我可以使用命令PowerShell_Ise -NoProfile运行带有 noprofile 的 Powershell Ise 。但是我们如何在 Visual Studio Code 中为 poershell 会话做同样的事情。