Visual Studio CodePowershellの起動エラー

Sep 11 2020

Widows Server 2012R2で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 '; Start-EditorServices -HostName' Visual Studio Code Host'-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 Integrated Console v2020.6.0 <===== "-LogLevel'Normal '-LogPath'c:\ Users \ first.last.vscode \ extensions \ ms-vscode.powershell-2020.6.0 \ logs \ 1599836315- 05dc7ac0-e011-4b28-8568-c8782ebeabc01599836314391 \ EditorServices.log'-SessionDetailsPath 'c:\ Users \ first.last.vscode \ extensions \ ms-vscode.powershell-2020.6.0 \ sessions \ PSES-VSCode-8808-389325' -FeatureFlags @()..。

hello worldテストスクリプトを実行しようとすると、次のようになります。

PowerShellセッションが開始されるまで、Powershellスクリプトをデバッグまたは実行できません。PowerShellセッションの開始が完了するのを待ってから、再試行してください。

出典:PowerShellプレビュー(拡張機能)

有効にするとすぐにエラーがスローされるため、MicrosoftのPowershell2020.6.0拡張機能に関連しているようです。

PowerShellを再び機能させる方法について何かアイデアはありますか?

回答

2 Yasutaka Oct 09 2020 at 16:13

ユーザー設定(JSON)に以下を追加してみてください。

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

どうやら、パラメータStart-EditorServicesを-StartupBanner指定して実行されているコマンドに文字(<)が含まれているため、エラーが発生しているようです。

上記の設定は、このエラーを解決するスタートアップバナーを抑制するように指示します。最終的にこの発見にたどり着くには、インターネットを介して何時間も精査しなければなりませんでした。PowershellCoreチームの誰かがこれを修正することを望みます。