一直但願在 Visual Studio Code 中使用 PowerShell,插件 CodeShell 提供了對於 PowerShell 的支持。git
首先按 F1,打開命令窗口,輸入安裝插件的命令。github
繼續輸入 powershell ,將會看到 PowerShell 相關的插件。shell
選擇 CodeShell 插件。json
一旦安裝完成,Visual Studio Code 會提示你從新啓動 Visual Studio Code,以便啓用這個插件。visual-studio-code
如今打開 PowerShell 窗口,就能夠直接使用快捷鍵了。瀏覽器
Ctrl + Alt + P 直接在當前項目的目錄中打開 PowerShello 窗口。編輯器
Ctrl + Alt + U 打開一個非限制的窗口。函數
固然了,PowerShell 只能在 Windows 平臺執行,在 Mac 平臺上,若是你決定開發 PowerShell 代碼,你固然不能 Debug 你的 PowerShell 代碼,可是,至少你能夠作下面的事情:visual-studio
固然了,在 Windows 系統中,本地的 PowerShell 能夠提供更多的支持,你能夠在 Code 中訪問更多的特性。感謝相似 PowerShell Editor Services and PowerShell Scrip Analyzer 這樣的項目,擴展的開發者實現了 Debug 特性和代碼分析的特性。下面是 Windows 平臺上的特性列表。spa
{ "version": "0.2.0", "configurations": [ { "name": "PowerShell", "type": "PowerShell", "program": "DebugTest.ps1" } ] }
一旦提供了文件名,就能夠執行調試了。
所以,你能夠簡單地使用 Code 做爲附帶大量特性的 PowerShell 的編輯器,甚至在 Linux 或者 Mac 平臺上,也仍然能夠提供一些支持特性。
參考:
https://blogs.msdn.microsoft.com/cdndevs/2015/12/11/visual-studio-code-powershell-extension/