PowerShell Strategies

Learn powerful PowerShell strategies to make your code faster, solve automation challenges, and become a better and more efficient PowerShell scripter.

There is a plethora of things you might want to automate with PowerShell. While we can’t provide you with ready-to-use solutions that match exactly your scenario, we sure can discuss typical cases and highlight some of the awesome features built into PowerShell and common strategies employed by professional scripters.

This section is a work in progress, and we are continuing to add articles, so please feel free to check back often.

Please take a look at the categories in the navigation bar. They range from performance optimization over looping concepts to typical network discovery needs. We provide thoroughly researched articles with many learning points to take home and hope you enjoy them.

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.

Image

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.