Comments
I'd like to introduce comments right at the beginning. As you may know (from other scripting or coding languages), comments are necessary to describe and explain your code. Developers often argue that code is self-explanatory, but that is a lie. You will quickly learn that, even when working with your own scripts, it is always good to have some comments on the side. You can use either line comments or comment blocks in PowerShell, which make use of the key character (#
), and look as follows:
# this is a comment line ## this as well <# this is a comment block #> <# this as well this as well this as well #>
As we are starting with the basics, you should know that there are some best practices for writing code. We will provide many of them throughout this book, but the most important one is to always provide comments with your code, to help the reader, other coders, or even yourself, if you need to reuse or debug your code. If you need to write multiline comments...