ความล้มเหลวในการเริ่มต้น Visual Studio Code Powershell

Sep 11 2020

ฉันใช้ VSCode เวอร์ชัน 1.49.0 การตั้งค่าผู้ใช้บน Widows Server 2012 R2 ฉันใช้มันเพื่อการพัฒนา powershell ฉันไม่มีปัญหานี้ในแล็ปท็อป windows 10 ของฉัน แต่ทำบนเซิร์ฟเวอร์ที่ฉันต้องทำงาน dev ของฉันเนื่องจากฉันเขียนโค้ดเทียบกับโมเดลวัตถุในสถานที่ของ SharePoint 2013

ฉันติดตั้ง Windows8.1-KB3118401 เมื่อเริ่มคอนโซลฉันจะได้รับสิ่งต่อไปนี้:

"C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', 'นำเข้าโมดูล' 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 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-393 -FeatureFlags @ () ...

เมื่อฉันพยายามเรียกใช้สคริปต์ทดสอบ hello world ฉันได้รับ:

ไม่สามารถดีบักหรือรันสคริปต์ Powershell ได้จนกว่าเซสชัน PowerShell จะเริ่มทำงาน รอให้เซสชัน PowerShell เสร็จสิ้นและลองอีกครั้ง

ที่มา: PowerShell Preview (ส่วนขยาย)

ดูเหมือนว่าจะเกี่ยวข้องกับส่วนขยาย Powershell 2020.6.0 จาก microsoft ทันทีที่ฉันเปิดใช้งานข้อผิดพลาดก็เกิดขึ้น

มีความคิดเกี่ยวกับวิธีทำให้ powershell ของฉันทำงานอีกครั้งหรือไม่?

คำตอบ

2 Yasutaka Oct 09 2020 at 16:13

ลองเพิ่มสิ่งต่อไปนี้ในการตั้งค่าผู้ใช้ (JSON)

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

เห็นได้ชัดว่าStart-EditorServicesคำสั่งที่ดำเนินการด้วย-StartupBannerพารามิเตอร์มีอักขระ ( <) ซึ่งดูเหมือนว่าจะมีข้อผิดพลาด

การตั้งค่าข้างต้นสั่งให้หยุดแบนเนอร์เริ่มต้นซึ่งจะแก้ไขข้อผิดพลาดนี้ ฉันต้องใช้เวลาหลายชั่วโมงในการกัดเซาะผ่านอินเทอร์เน็ตเพื่อให้ได้มาซึ่งการค้นพบนี้ในที่สุด ต้องการให้ใครสักคนในทีม Powershell Core แก้ไขปัญหานี้