小编Moo*_*ose的帖子

PowerShell 7 使用 Chocolatey 作为 PackageManager

PowerShell 5 和 7 在 PackageManager 方面仍然不同。
Chocolatey 似乎尚未“集成”,我无法像在 PowerShell 5 中那样在 PowerShell 7 中使用 Chocolatey。

我已经按照他们网站所说的方式安装了 Chocolatey,但这让我可以使用 Chocolatey 来启动我的 choco 命令。

如何在 PowerShell 7 中配置 Chocolatey,以便可以像在 PowerShell 5 中一样使用它。
Find-Package -ProviderName Chocolatey -Name <packagename>

powershell package-managers package chocolatey

4
推荐指数
1
解决办法
3285
查看次数

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
查看次数