| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
If you are working on Linux and macOS, you cannot use the PowerShell ISE because it is not supported on these platforms. In this case, you can choose your favorite editor to write PowerShell scripts. Here we choose Visual Studio Code as a PowerShell editor.
You can use Visual Studio Code on Windows with PowerShell version 5 by using Windows 10 or by installing Windows Management Framework 5.0 RTM for down-level Windows OSs (e.g. Windows 8.1, etc.).
Before starting it, please make sure PowerShell exists on your system. By following the Installing PowerShell instructions you can install PowerShell and launch a PowerShell session.
1. Installing Visual Studio Code
Linux: follow the installation instructions on the Running VS Code on Linux page
macOS: follow the installation instructions on the Running VS Code on macOS page
NOTE: On OS X you must install OpenSSL for the PowerShell extension to work correctly. The easiest way to accomplish this is to install Homebrew and then run brew install openssl. The PowerShell extension will now be able to load successfully.
Windows: follow the installation instructions on the Running VS Code on Windows page
2. Installing PowerShell Extension
If you wish to use a specific installation of PowerShell with Visual Studio Code, you will need to add a new variable to your user settings file.
// On Windows:
"powershell.developer.powerShellExePath": "c:/Program Files/PowerShell/<version>/powershell.exe"
// On Linux:
"powershell.developer.powerShellExePath": "/opt/microsoft/powershell/<version>/powershell"
// On macOS:
"powershell.developer.powerShellExePath": "/usr/local/microsoft/powershell/<version>/powershell"Open a file folder (File->Open Folder) that contains the PowerShell modules or scripts you have written already and want to debug. In this example, we saved the helloworld.ps1 under a directory called "demo". Thus we select the "demo" folder and open it in Visual Studio Code.
Creating the Debug Configuration (launch.json)
Because some information regarding your scripts is needed for debugger to start executing your script, we need to set up the debug config first. This is one-time process to debug PowerShell scripts under your current folder. In our case, the "demo" folder.
{
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell",
"type": "PowerShell",
"request": "launch",
"program": "${file}",
"args": [],
"cwd": "${file}"
}
]
}There are a few blogs that may be helpful to get you started using PowerShell extension for Visual Studio Code
The PowerShell extension's source code can be found on GitHub.
| Back | FazBrowse Home | New Git URL |