【问题标题】:Visual Studio Code Powershell startup failureVisual Studio Code Powershell 启动失败
【发布时间】:2020-12-30 04:05:57
【问题描述】:

我在 Widows Server 2012 R2 上使用 VSCode 版本 1.49.0 用户设置。我用它来开发powershell。我的 Windows 10 笔记本电脑上没有这个问题,但在我需要进行开发工作的服务器上却有,因为我针对 sharepoint 2013 本地对象模型编写代码。

我安装了 Windows8.1-KB3118401 当启动控制台时,我得到以下信息:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', 'Import-Module'c :\Users\first.last.vscode\extensions\ms-vscode.powershell-2020.6.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; 开始-EditorServices -HostName 'Visual Studio 代码主机' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.6.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\first.last.vscode\extensions\ms-vscode.powershell-2020.6.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell 集成控制台 v2020.6.0

当我尝试运行 hello world 测试脚本时,我得到:

在 PowerShell 会话之前无法调试或运行 Powershell 脚本 已经开始。等待 PowerShell 会话完成启动并尝试 再次。

来源:PowerShell 预览(扩展)

这似乎与微软的 Powershell 2020.6.0 扩展有关,因为一旦我启用它就会引发错误。

知道如何让我的 powershell 再次工作吗?

【问题讨论】:

    标签: visual-studio-code powershell-4.0


    【解决方案1】:

    尝试在您的用户设置 (JSON) 中添加以下内容。

    {
      "powershell.integratedConsole.suppressStartupBanner": true,
    }
    

    显然,使用-StartupBanner 参数执行的Start-EditorServices 命令包含一个字符(<),这似乎引发了错误。

    上述设置指示禁止启动横幅,从而解决此错误。我不得不花这么多小时在互联网上搜索才能最终找到这个发现。希望 Powershell Core 团队中的某个人能解决这个问题。

    【讨论】:

    • 它对我有用,如下所示:转到路径并编辑 > "C:\Users\Name\.vscode\argv.json" 并添加行 > "powershell.integratedConsole.suppressStar 谢谢。
    • 我试过了,效果很好..谢谢
    【解决方案2】:

    我收到这个错误是因为我使用的是 PowerShell 4(任何小于 5 的东西显然都有这个问题)。

    你可以通过这个命令找出你正在使用的 PS 版本: Get-Host | Select-Object Version

    这里有如何安装旧版本的 PowerShell 扩展的指南: https://docs.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/using-vscode?view=powershell-7.1#using-an-older-version-of-the-powershell-extension-for-windows-powershell-v3-and-v4

    但简而言之,它说:

    1. 右键单击 PowerShell 扩展并选择“安装另一个版本...”
    2. 选择版本“2020.1.0”。

    它还建议禁用自动更新。 X

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-29
      • 2018-07-06
      • 2022-11-02
      • 2020-06-17
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多