Basics

For the first step, we should find the PowerShell console in VSCode. For this, press on TERMINAL. We validate the started PowerShell version with $PSVersionTable and you can see that the default PowerShell version running on a Windows 10 environment is loaded:

So, in this console, you have the same possibilities as working directly with PowerShell.exe.

Next, we want to create a new script. For this, we create a new workspace folder and add a new file, test.ps1, to it. It is self-explanatory and should look similar to this, when you have finished:

You can now start writing your scripts and make use of IntelliSense. In the next screenshot, we are coding in the test.ps1 file. Just try to write get-se to see how it is working:

By just focusing on one cmdlet with the arrow keys, additional cmdlet information is shown. You can also test the debugging mechanisms, which will work mostly the same as in the ISE. You have some more capabilities for debugging and customization options for the whole editor. As for now, we will keep it like this. Later in the book, we will take a dedicated look at how to create reusable code and how to benefit in the same spot from the possibilities within VSCode. In the next two chapters, we will learn how to write PowerShell code. All of the demo code can be executed in PowerShell files. The whole scripts are available in GitHub and you can just open the folder.

To get an overview of all of the capabilities of VSCode, you should go through the following two resources step by step:

https://code.visualstudio.com/docs/
https://github.com/Microsoft/vscode-tips-and-tricks

Because of the complexity and variety of configuration possibilities and the continuously developing feature set of VSCode, only the most important mechanisms can be covered in this book.

Therefore, you should take these two resources as required learning material.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset