90% of scripters use 30% of features. It is amazing to see how many extremely powerful features were added to PowerShell over the time and went mostly unnoticed.
We change this and document some of the lesser-known fundamental features built into PowerShell so you can finally discover and understand them and use them to improve your code.
Articles are categorized in the navigation bar: we are looking at the parser and Abstract Syntax Tree (AST), investigate the power of attributes, look at code completion techniques that make your functions so much easier to use, and constantly add new articles when we stumble across new things and find the time.
If you’d like to point us to something you discovered, please leave a comment below!
Our browser of choice is Google Chrome: it is most widely used and based on Chromium. Chromium is used by an increasing number of other browsers including the new Microsoft Edge browser. We also regularly test with most mobile browsers like Safari.
We cannot test with every browser out there. If you are using a different browser, the website features described below may not work as expected.
Learning From Example Code
A working example tells usually more than a thousand words. That’s why all articles come with tons of ready-to-use and tested PowerShell sample code. Here are some guidelines how to best work with it.
Scrolling Code
All code samples are displayed without word wrap to minimize confusion about where a code line ends.
When code does not fit, we do not show scrollbars unless you hover over the code example for a good reading experience. When you hover over code examples, a horizontal scrollbar shows.
On mobile devices, to scroll example code, tap anywhere into the example code box, then slide the code to the right or left.
Example Code
First and foremost: understand any code before you run it! While we do not publish dangerous code, there may occasionally be risk attached, i.e. when code illustrates how to change system settings.
Please avoid running code examples out of context: in order to minimize redundant code and focus on the relevant things, our articles typically explain features or strategies step by step. A given code example may require that you ran other code from a previous example before, i.e. to define a function or extension.
For complex code examples, our articles typically show a complete example at the beginning or the end, or reference to PowerShell modules where you can load the entire code.
Running Example Code
To run example code, click the icon in the upper right corner of each code sample box. This automatically selects all code in your browser and copies it to the clipboard. From there, paste it into the editor of choice, i.e. ISE or VSCode.
While you can paste code into PowerShell console windows, this is not recommended for larger portions of code as PowerShell accepts multi-line code line-by-line and may start executing lines while others are still pasted.
License
All of our articles are licensed under a Attribution-NoDerivatives 4.0 International license, so you cannot publish them (or parts) in magazines, your website, or any other place without our written permission. Unfortunately, in the past we have seen websites and magazines harvest articles and tricks, and publish them under their name (which is obviously violating community spirit).
Code Is Public Domain
All code is licensed under a very permissive Attribution 4.0 International license, so you can use any code freely, even in commercial projects. You can use the code as-is or use it as a start for your own scripts. Obviously we would love to be mentioned if you do but that is no requirement.
All code samples are published as-is without warranty of any kind. Use code exclusively at your own risk and discretion.
Help Improve And Add Your Wisdom!
Please do leave comments below articles if you have questions, would like to add wisdom or a new point of view, or just indicate that you found something useful. We like to hear from you.