代码之家  ›  专栏  ›  技术社区  ›  Vandrey Trindade

有没有办法在Visual Studio代码上使用PowerShell ISE加载项?

  •  1
  • Vandrey Trindade  · 技术社区  · 7 年前

    我现在正在尝试从PowerShell ISE迁移到Visual Studio代码,但我找不到使用附加组件的方法。有什么提示吗?

    2 回复  |  直到 7 年前
        1
  •  0
  •   alroc    7 年前

        2
  •  -1
  •   Vandrey Trindade    5 年前

    我终于找到了解决办法!(对不起,我会纠正我的错误并在这里发布解决方案,而不仅仅是链接…)

    在配置文件脚本文件中,添加以下内容:

    Function Connect_PowerCLI {
        $VMwareCredential = Get-Credential
        $ESXiHosts = @("esxi01","esxi02","esxi03")
        $ESXiHosts | ForEach-Object {
            Connect-VIServer -Server $_ -Credential $VMwareCredential
        }
    }
    Register-EditorCommand -Name Connect_PowerCLI -DisplayName "Connect on all ESXi hosts using VMware PowerCLI" -Function Connect_PowerCLI
    

    配置VSCode快捷方式:

    {
      "key": "shift+alt+s",
      "command": "PowerShell.ShowAdditionalCommands",
      "when": "editorTextFocus && editorLangId == 'powershell'"
    }
    

    Jeffery Hicks原创帖子: https://jdhitsolutions.com/blog/powershell/5907/extending-vscode-with-powershell